@wordpress/block-library 8.30.0 → 8.32.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 (362) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/build/block/edit.js +22 -16
  3. package/build/block/edit.js.map +1 -1
  4. package/build/button/edit.native.js +1 -1
  5. package/build/button/edit.native.js.map +1 -1
  6. package/build/code/save.js +3 -1
  7. package/build/code/save.js.map +1 -1
  8. package/build/cover/edit/index.js +2 -1
  9. package/build/cover/edit/index.js.map +1 -1
  10. package/build/details/edit.js +1 -0
  11. package/build/details/edit.js.map +1 -1
  12. package/build/file/edit.js +2 -0
  13. package/build/file/edit.js.map +1 -1
  14. package/build/heading/index.js +4 -3
  15. package/build/heading/index.js.map +1 -1
  16. package/build/image/edit.js +10 -39
  17. package/build/image/edit.js.map +1 -1
  18. package/build/image/image.js +27 -6
  19. package/build/image/image.js.map +1 -1
  20. package/build/media-text/edit.js +33 -9
  21. package/build/media-text/edit.js.map +1 -1
  22. package/build/media-text/index.js +5 -0
  23. package/build/media-text/index.js.map +1 -1
  24. package/build/media-text/media-container.js +30 -11
  25. package/build/media-text/media-container.js.map +1 -1
  26. package/build/media-text/save.js +2 -2
  27. package/build/media-text/save.js.map +1 -1
  28. package/build/navigation/edit/index.js +23 -29
  29. package/build/navigation/edit/index.js.map +1 -1
  30. package/build/navigation/edit/navigation-menu-delete-control.js +12 -20
  31. package/build/navigation/edit/navigation-menu-delete-control.js.map +1 -1
  32. package/build/navigation/edit/navigation-menu-selector.js +24 -23
  33. package/build/navigation/edit/navigation-menu-selector.js.map +1 -1
  34. package/build/navigation/edit/placeholder/index.js +4 -4
  35. package/build/navigation/edit/placeholder/index.js.map +1 -1
  36. package/build/navigation/use-navigation-menu.js +15 -12
  37. package/build/navigation/use-navigation-menu.js.map +1 -1
  38. package/build/navigation/view.js +12 -2
  39. package/build/navigation/view.js.map +1 -1
  40. package/build/navigation-link/edit.js +52 -27
  41. package/build/navigation-link/edit.js.map +1 -1
  42. package/build/navigation-submenu/edit.js +31 -9
  43. package/build/navigation-submenu/edit.js.map +1 -1
  44. package/build/pattern/edit.js +3 -1
  45. package/build/pattern/edit.js.map +1 -1
  46. package/build/post-author/edit.js +1 -0
  47. package/build/post-author/edit.js.map +1 -1
  48. package/build/post-excerpt/edit.js +1 -0
  49. package/build/post-excerpt/edit.js.map +1 -1
  50. package/build/post-featured-image/edit.js +16 -4
  51. package/build/post-featured-image/edit.js.map +1 -1
  52. package/build/post-featured-image/index.js +13 -2
  53. package/build/post-featured-image/index.js.map +1 -1
  54. package/build/post-featured-image/overlay-controls.js +82 -0
  55. package/build/post-featured-image/overlay-controls.js.map +1 -0
  56. package/build/post-featured-image/overlay.js +5 -54
  57. package/build/post-featured-image/overlay.js.map +1 -1
  58. package/build/post-navigation-link/edit.js +1 -0
  59. package/build/post-navigation-link/edit.js.map +1 -1
  60. package/build/post-terms/edit.js +2 -0
  61. package/build/post-terms/edit.js.map +1 -1
  62. package/build/quote/edit.js +18 -23
  63. package/build/quote/edit.js.map +1 -1
  64. package/build/read-more/edit.js +1 -0
  65. package/build/read-more/edit.js.map +1 -1
  66. package/build/search/edit.js +2 -0
  67. package/build/search/edit.js.map +1 -1
  68. package/build/search/edit.native.js +2 -2
  69. package/build/search/edit.native.js.map +1 -1
  70. package/build/site-tagline/edit.js +13 -4
  71. package/build/site-tagline/edit.js.map +1 -1
  72. package/build/site-tagline/index.js +4 -0
  73. package/build/site-tagline/index.js.map +1 -1
  74. package/build/social-link/edit.js +1 -1
  75. package/build/social-link/edit.js.map +1 -1
  76. package/build/social-link/icons/medium.js +1 -1
  77. package/build/social-link/icons/medium.js.map +1 -1
  78. package/build/social-link/icons/reddit.js +1 -1
  79. package/build/social-link/icons/reddit.js.map +1 -1
  80. package/build/table/deprecated.js +285 -175
  81. package/build/table/deprecated.js.map +1 -1
  82. package/build/table/index.js +1 -1
  83. package/build/template-part/edit/index.js +55 -47
  84. package/build/template-part/edit/index.js.map +1 -1
  85. package/build/template-part/edit/inner-blocks.js +106 -10
  86. package/build/template-part/edit/inner-blocks.js.map +1 -1
  87. package/build/template-part/edit/selection-modal.js +1 -9
  88. package/build/template-part/edit/selection-modal.js.map +1 -1
  89. package/build/utils/caption.js +19 -13
  90. package/build/utils/caption.js.map +1 -1
  91. package/build/utils/hooks.js +1 -0
  92. package/build/utils/hooks.js.map +1 -1
  93. package/build/video/edit.native.js +1 -1
  94. package/build/video/edit.native.js.map +1 -1
  95. package/build-module/block/edit.js +23 -17
  96. package/build-module/block/edit.js.map +1 -1
  97. package/build-module/button/edit.native.js +1 -1
  98. package/build-module/button/edit.native.js.map +1 -1
  99. package/build-module/code/save.js +3 -1
  100. package/build-module/code/save.js.map +1 -1
  101. package/build-module/cover/edit/index.js +2 -1
  102. package/build-module/cover/edit/index.js.map +1 -1
  103. package/build-module/details/edit.js +1 -0
  104. package/build-module/details/edit.js.map +1 -1
  105. package/build-module/file/edit.js +2 -0
  106. package/build-module/file/edit.js.map +1 -1
  107. package/build-module/heading/index.js +4 -3
  108. package/build-module/heading/index.js.map +1 -1
  109. package/build-module/image/edit.js +11 -40
  110. package/build-module/image/edit.js.map +1 -1
  111. package/build-module/image/image.js +27 -6
  112. package/build-module/image/image.js.map +1 -1
  113. package/build-module/media-text/edit.js +34 -10
  114. package/build-module/media-text/edit.js.map +1 -1
  115. package/build-module/media-text/index.js +5 -0
  116. package/build-module/media-text/index.js.map +1 -1
  117. package/build-module/media-text/media-container.js +31 -12
  118. package/build-module/media-text/media-container.js.map +1 -1
  119. package/build-module/media-text/save.js +2 -2
  120. package/build-module/media-text/save.js.map +1 -1
  121. package/build-module/navigation/edit/index.js +24 -30
  122. package/build-module/navigation/edit/index.js.map +1 -1
  123. package/build-module/navigation/edit/navigation-menu-delete-control.js +15 -23
  124. package/build-module/navigation/edit/navigation-menu-delete-control.js.map +1 -1
  125. package/build-module/navigation/edit/navigation-menu-selector.js +24 -23
  126. package/build-module/navigation/edit/navigation-menu-selector.js.map +1 -1
  127. package/build-module/navigation/edit/placeholder/index.js +4 -4
  128. package/build-module/navigation/edit/placeholder/index.js.map +1 -1
  129. package/build-module/navigation/use-navigation-menu.js +15 -12
  130. package/build-module/navigation/use-navigation-menu.js.map +1 -1
  131. package/build-module/navigation/view.js +12 -2
  132. package/build-module/navigation/view.js.map +1 -1
  133. package/build-module/navigation-link/edit.js +55 -30
  134. package/build-module/navigation-link/edit.js.map +1 -1
  135. package/build-module/navigation-submenu/edit.js +31 -9
  136. package/build-module/navigation-submenu/edit.js.map +1 -1
  137. package/build-module/pattern/edit.js +3 -1
  138. package/build-module/pattern/edit.js.map +1 -1
  139. package/build-module/post-author/edit.js +1 -0
  140. package/build-module/post-author/edit.js.map +1 -1
  141. package/build-module/post-excerpt/edit.js +1 -0
  142. package/build-module/post-excerpt/edit.js.map +1 -1
  143. package/build-module/post-featured-image/edit.js +17 -5
  144. package/build-module/post-featured-image/edit.js.map +1 -1
  145. package/build-module/post-featured-image/index.js +13 -2
  146. package/build-module/post-featured-image/index.js.map +1 -1
  147. package/build-module/post-featured-image/overlay-controls.js +75 -0
  148. package/build-module/post-featured-image/overlay-controls.js.map +1 -0
  149. package/build-module/post-featured-image/overlay.js +7 -56
  150. package/build-module/post-featured-image/overlay.js.map +1 -1
  151. package/build-module/post-navigation-link/edit.js +1 -0
  152. package/build-module/post-navigation-link/edit.js.map +1 -1
  153. package/build-module/post-terms/edit.js +2 -0
  154. package/build-module/post-terms/edit.js.map +1 -1
  155. package/build-module/quote/edit.js +20 -25
  156. package/build-module/quote/edit.js.map +1 -1
  157. package/build-module/read-more/edit.js +1 -0
  158. package/build-module/read-more/edit.js.map +1 -1
  159. package/build-module/search/edit.js +2 -0
  160. package/build-module/search/edit.js.map +1 -1
  161. package/build-module/search/edit.native.js +2 -2
  162. package/build-module/search/edit.native.js.map +1 -1
  163. package/build-module/site-tagline/edit.js +14 -5
  164. package/build-module/site-tagline/edit.js.map +1 -1
  165. package/build-module/site-tagline/index.js +4 -0
  166. package/build-module/site-tagline/index.js.map +1 -1
  167. package/build-module/social-link/edit.js +1 -1
  168. package/build-module/social-link/edit.js.map +1 -1
  169. package/build-module/social-link/icons/medium.js +1 -1
  170. package/build-module/social-link/icons/medium.js.map +1 -1
  171. package/build-module/social-link/icons/reddit.js +1 -1
  172. package/build-module/social-link/icons/reddit.js.map +1 -1
  173. package/build-module/table/deprecated.js +286 -176
  174. package/build-module/table/deprecated.js.map +1 -1
  175. package/build-module/table/index.js +1 -1
  176. package/build-module/template-part/edit/index.js +58 -50
  177. package/build-module/template-part/edit/index.js.map +1 -1
  178. package/build-module/template-part/edit/inner-blocks.js +108 -12
  179. package/build-module/template-part/edit/inner-blocks.js.map +1 -1
  180. package/build-module/template-part/edit/selection-modal.js +2 -10
  181. package/build-module/template-part/edit/selection-modal.js.map +1 -1
  182. package/build-module/utils/caption.js +19 -13
  183. package/build-module/utils/caption.js.map +1 -1
  184. package/build-module/utils/hooks.js +1 -0
  185. package/build-module/utils/hooks.js.map +1 -1
  186. package/build-module/video/edit.native.js +1 -1
  187. package/build-module/video/edit.native.js.map +1 -1
  188. package/build-style/audio/theme-rtl.css +1 -1
  189. package/build-style/audio/theme.css +1 -1
  190. package/build-style/cover/style-rtl.css +5 -2
  191. package/build-style/cover/style.css +5 -2
  192. package/build-style/editor-rtl.css +22 -12
  193. package/build-style/editor.css +22 -12
  194. package/build-style/embed/theme-rtl.css +1 -1
  195. package/build-style/embed/theme.css +1 -1
  196. package/build-style/file/editor-rtl.css +3 -0
  197. package/build-style/file/editor.css +3 -0
  198. package/build-style/image/editor-rtl.css +0 -3
  199. package/build-style/image/editor.css +0 -3
  200. package/build-style/image/theme-rtl.css +1 -1
  201. package/build-style/image/theme.css +1 -1
  202. package/build-style/media-text/editor-rtl.css +7 -1
  203. package/build-style/media-text/editor.css +7 -1
  204. package/build-style/pullquote/theme-rtl.css +2 -1
  205. package/build-style/pullquote/theme.css +2 -1
  206. package/build-style/quote/theme-rtl.css +6 -6
  207. package/build-style/quote/theme.css +6 -6
  208. package/build-style/search/style-rtl.css +10 -0
  209. package/build-style/search/style.css +10 -0
  210. package/build-style/social-links/editor-rtl.css +0 -4
  211. package/build-style/social-links/editor.css +0 -4
  212. package/build-style/social-links/style-rtl.css +2 -2
  213. package/build-style/social-links/style.css +2 -2
  214. package/build-style/style-rtl.css +17 -4
  215. package/build-style/style.css +17 -4
  216. package/build-style/table/theme-rtl.css +4 -3
  217. package/build-style/table/theme.css +4 -3
  218. package/build-style/template-part/editor-rtl.css +12 -4
  219. package/build-style/template-part/editor.css +12 -4
  220. package/build-style/template-part/theme-rtl.css +1 -1
  221. package/build-style/template-part/theme.css +1 -1
  222. package/build-style/theme-rtl.css +17 -15
  223. package/build-style/theme.css +17 -15
  224. package/build-style/video/theme-rtl.css +1 -1
  225. package/build-style/video/theme.css +1 -1
  226. package/package.json +34 -34
  227. package/src/archives/index.php +4 -0
  228. package/src/audio/theme.scss +1 -1
  229. package/src/avatar/index.php +6 -0
  230. package/src/block/edit.js +43 -32
  231. package/src/block/index.php +4 -0
  232. package/src/block/test/edit.native.js +67 -0
  233. package/src/button/edit.native.js +1 -1
  234. package/src/calendar/index.php +12 -0
  235. package/src/categories/index.php +6 -0
  236. package/src/code/save.js +7 -1
  237. package/src/comment-author-name/index.php +4 -0
  238. package/src/comment-content/index.php +4 -0
  239. package/src/comment-date/index.php +4 -0
  240. package/src/comment-edit-link/index.php +4 -0
  241. package/src/comment-reply-link/index.php +4 -0
  242. package/src/comment-template/index.php +4 -0
  243. package/src/comments/index.php +10 -0
  244. package/src/comments-pagination/index.php +4 -0
  245. package/src/comments-pagination-next/index.php +4 -0
  246. package/src/comments-pagination-numbers/index.php +4 -0
  247. package/src/comments-pagination-previous/index.php +4 -0
  248. package/src/comments-title/index.php +4 -0
  249. package/src/cover/edit/index.js +4 -1
  250. package/src/cover/index.php +4 -0
  251. package/src/cover/style.scss +6 -2
  252. package/src/details/edit.js +1 -0
  253. package/src/embed/theme.scss +1 -1
  254. package/src/file/edit.js +2 -0
  255. package/src/file/editor.scss +3 -0
  256. package/src/file/index.php +4 -0
  257. package/src/gallery/editor.scss +1 -1
  258. package/src/gallery/index.php +7 -1
  259. package/src/heading/index.js +4 -3
  260. package/src/heading/index.php +4 -0
  261. package/src/home-link/index.php +10 -0
  262. package/src/image/edit.js +11 -40
  263. package/src/image/editor.scss +2 -7
  264. package/src/image/image.js +25 -7
  265. package/src/image/index.php +12 -1
  266. package/src/image/theme.scss +1 -1
  267. package/src/latest-comments/index.php +4 -0
  268. package/src/latest-posts/index.php +8 -0
  269. package/src/loginout/index.php +4 -0
  270. package/src/media-text/block.json +5 -0
  271. package/src/media-text/edit.js +70 -19
  272. package/src/media-text/editor.scss +7 -1
  273. package/src/media-text/index.php +70 -0
  274. package/src/media-text/media-container.js +49 -9
  275. package/src/media-text/save.js +2 -2
  276. package/src/navigation/edit/index.js +67 -71
  277. package/src/navigation/edit/navigation-menu-delete-control.js +22 -49
  278. package/src/navigation/edit/navigation-menu-selector.js +39 -21
  279. package/src/navigation/edit/placeholder/index.js +4 -4
  280. package/src/navigation/edit/test/navigation-menu-selector.js +75 -53
  281. package/src/navigation/index.php +109 -26
  282. package/src/navigation/test/use-navigation-menu.js +21 -21
  283. package/src/navigation/use-navigation-menu.js +23 -9
  284. package/src/navigation/view.js +11 -2
  285. package/src/navigation-link/edit.js +64 -39
  286. package/src/navigation-link/index.php +14 -0
  287. package/src/navigation-submenu/edit.js +34 -10
  288. package/src/navigation-submenu/index.php +8 -0
  289. package/src/page-list/index.php +12 -0
  290. package/src/page-list-item/index.php +2 -0
  291. package/src/pattern/edit.js +4 -0
  292. package/src/pattern/index.php +2 -0
  293. package/src/post-author/edit.js +1 -0
  294. package/src/post-author/index.php +4 -0
  295. package/src/post-author-biography/index.php +4 -0
  296. package/src/post-author-name/index.php +4 -0
  297. package/src/post-comments-form/index.php +6 -0
  298. package/src/post-content/index.php +4 -0
  299. package/src/post-date/index.php +4 -0
  300. package/src/post-excerpt/edit.js +1 -0
  301. package/src/post-excerpt/index.php +4 -0
  302. package/src/post-featured-image/block.json +13 -2
  303. package/src/post-featured-image/edit.js +16 -1
  304. package/src/post-featured-image/editor.scss +1 -1
  305. package/src/post-featured-image/index.php +15 -0
  306. package/src/post-featured-image/overlay-controls.js +88 -0
  307. package/src/post-featured-image/overlay.js +17 -84
  308. package/src/post-navigation-link/edit.js +1 -0
  309. package/src/post-navigation-link/index.php +4 -0
  310. package/src/post-template/index.php +4 -0
  311. package/src/post-terms/edit.js +2 -0
  312. package/src/post-terms/index.php +6 -0
  313. package/src/post-title/index.php +2 -0
  314. package/src/pullquote/theme.scss +3 -1
  315. package/src/query/index.php +2 -0
  316. package/src/query-no-results/index.php +6 -0
  317. package/src/query-pagination/index.php +4 -0
  318. package/src/query-pagination-next/index.php +6 -0
  319. package/src/query-pagination-numbers/index.php +6 -0
  320. package/src/query-pagination-previous/index.php +4 -0
  321. package/src/query-title/index.php +4 -0
  322. package/src/quote/edit.js +27 -37
  323. package/src/quote/test/edit.native.js +4 -6
  324. package/src/quote/theme.scss +1 -2
  325. package/src/read-more/edit.js +1 -0
  326. package/src/read-more/index.php +4 -0
  327. package/src/rss/index.php +4 -0
  328. package/src/search/edit.js +2 -0
  329. package/src/search/edit.native.js +2 -2
  330. package/src/search/index.php +19 -1
  331. package/src/search/style.scss +11 -0
  332. package/src/shortcode/index.php +4 -0
  333. package/src/site-logo/editor.scss +2 -2
  334. package/src/site-logo/index.php +20 -0
  335. package/src/site-tagline/block.json +4 -0
  336. package/src/site-tagline/edit.js +16 -3
  337. package/src/site-tagline/index.php +13 -1
  338. package/src/site-title/index.php +4 -0
  339. package/src/social-link/edit.js +1 -1
  340. package/src/social-link/icons/medium.js +1 -1
  341. package/src/social-link/icons/reddit.js +1 -1
  342. package/src/social-link/index.php +22 -9
  343. package/src/social-link/socials-with-bg.scss +1 -1
  344. package/src/social-link/socials-without-bg.scss +1 -1
  345. package/src/social-links/editor.scss +1 -9
  346. package/src/table/block.json +1 -1
  347. package/src/table/deprecated.js +308 -175
  348. package/src/table/theme.scss +4 -2
  349. package/src/tag-cloud/index.php +4 -0
  350. package/src/template-part/edit/index.js +87 -79
  351. package/src/template-part/edit/inner-blocks.js +126 -13
  352. package/src/template-part/edit/selection-modal.js +1 -22
  353. package/src/template-part/editor.scss +11 -3
  354. package/src/template-part/index.php +12 -0
  355. package/src/template-part/theme.scss +1 -1
  356. package/src/term-description/index.php +4 -0
  357. package/src/utils/caption.js +19 -16
  358. package/src/utils/hooks.js +1 -0
  359. package/src/video/edit.native.js +2 -0
  360. package/src/video/editor.scss +2 -2
  361. package/src/video/theme.scss +1 -1
  362. package/tsconfig.json +1 -0
@@ -1,12 +1,7 @@
1
1
  // Provide special styling for the placeholder.
2
- // @todo: this particular minimal style of placeholder could be componentized further.
2
+ // @todo this particular minimal style of placeholder could be componentized further.
3
3
  .wp-block-image.wp-block-image {
4
4
 
5
- &:not(.is-selected) .components-placeholder__fieldset {
6
- // Show only is selected.
7
- display: none;
8
- }
9
-
10
5
  // Show Placeholder style on-select.
11
6
  &.is-selected .components-placeholder {
12
7
  // Block UI appearance.
@@ -18,7 +13,7 @@
18
13
  // Disable any duotone filter applied in the selected state.
19
14
  filter: none !important;
20
15
 
21
- // @todo: this should eventually be overridden by a custom border-radius set in the inspector.
16
+ // @todo this should eventually be overridden by a custom border-radius set in the inspector.
22
17
  border-radius: $radius-block-ui;
23
18
 
24
19
  > svg {
@@ -83,8 +83,7 @@ const ImageWrapper = ( { href, children } ) => {
83
83
  // When the Image block is linked,
84
84
  // it's wrapped with a disabled <a /> tag.
85
85
  // Restore cursor style so it doesn't appear 'clickable'
86
- // and remove pointer events. Safari needs the display property.
87
- pointerEvents: 'none',
86
+ // Safari needs the display property.
88
87
  cursor: 'default',
89
88
  display: 'inline',
90
89
  } }
@@ -274,6 +273,22 @@ export default function Image( {
274
273
  }
275
274
  }
276
275
 
276
+ function resetLightbox() {
277
+ // When deleting a link from an image while lightbox settings
278
+ // are enabled by default, we should disable the lightbox,
279
+ // otherwise the resulting UX looks like a mistake.
280
+ // See https://github.com/WordPress/gutenberg/pull/59890/files#r1532286123.
281
+ if ( lightboxSetting?.enabled && lightboxSetting?.allowEditing ) {
282
+ setAttributes( {
283
+ lightbox: { enabled: false },
284
+ } );
285
+ } else {
286
+ setAttributes( {
287
+ lightbox: undefined,
288
+ } );
289
+ }
290
+ }
291
+
277
292
  function onSetTitle( value ) {
278
293
  // This is the HTML title attribute, separate from the media object
279
294
  // title.
@@ -348,7 +363,10 @@ export default function Image( {
348
363
  const [ lightboxSetting ] = useSettings( 'lightbox' );
349
364
 
350
365
  const showLightboxSetting =
351
- !! lightbox || lightboxSetting?.allowEditing === true;
366
+ // If a block-level override is set, we should give users the option to
367
+ // remove that override, even if the lightbox UI is disabled in the settings.
368
+ ( !! lightbox && lightbox?.enabled !== lightboxSetting?.enabled ) ||
369
+ lightboxSetting?.allowEditing;
352
370
 
353
371
  const lightboxChecked =
354
372
  !! lightbox?.enabled || ( ! lightbox && !! lightboxSetting?.enabled );
@@ -498,6 +516,7 @@ export default function Image( {
498
516
  showLightboxSetting={ showLightboxSetting }
499
517
  lightboxEnabled={ lightboxChecked }
500
518
  onSetLightbox={ onSetLightbox }
519
+ resetLightbox={ resetLightbox }
501
520
  />
502
521
  ) }
503
522
  { allowCrop && (
@@ -692,6 +711,7 @@ export default function Image( {
692
711
  <InspectorControls group="advanced">
693
712
  <TextControl
694
713
  __nextHasNoMarginBottom
714
+ __next40pxDefaultSize
695
715
  label={ __( 'Title attribute' ) }
696
716
  value={ title || '' }
697
717
  onChange={ onSetTitle }
@@ -913,9 +933,7 @@ export default function Image( {
913
933
 
914
934
  return (
915
935
  <>
916
- { /* Hide controls during upload to avoid component remount,
917
- which causes duplicated image upload. */ }
918
- { ! temporaryURL && controls }
936
+ { controls }
919
937
  { img }
920
938
 
921
939
  <Caption
@@ -925,7 +943,7 @@ export default function Image( {
925
943
  insertBlocksAfter={ insertBlocksAfter }
926
944
  label={ __( 'Image caption text' ) }
927
945
  showToolbarButton={ isSingleSelected && hasNonContentControls }
928
- disableEditing={ lockCaption }
946
+ readOnly={ lockCaption }
929
947
  />
930
948
  </>
931
949
  );
@@ -9,6 +9,8 @@
9
9
  * Renders the `core/image` block on the server,
10
10
  * adding a data-id attribute to the element if core/gallery has added on pre-render.
11
11
  *
12
+ * @since 5.9.0
13
+ *
12
14
  * @param array $attributes The block attributes.
13
15
  * @param string $content The block content.
14
16
  * @param WP_Block $block The block object.
@@ -85,6 +87,8 @@ function render_block_core_image( $attributes, $content, $block ) {
85
87
  *
86
88
  * This is used to determine whether the lightbox should be rendered or not.
87
89
  *
90
+ * @since 6.4.0
91
+ *
88
92
  * @param array $block Block data.
89
93
  *
90
94
  * @return array Filtered block data.
@@ -115,6 +119,8 @@ function block_core_image_get_lightbox_settings( $block ) {
115
119
  /**
116
120
  * Adds the directives and layout needed for the lightbox behavior.
117
121
  *
122
+ * @since 6.4.0
123
+ *
118
124
  * @param string $block_content Rendered block content.
119
125
  * @param array $block Block object.
120
126
  *
@@ -219,6 +225,9 @@ function block_core_image_render_lightbox( $block_content, $block ) {
219
225
  return $body_content;
220
226
  }
221
227
 
228
+ /**
229
+ * @since 6.5.0
230
+ */
222
231
  function block_core_image_print_lightbox_overlay() {
223
232
  $close_button_label = esc_attr__( 'Close' );
224
233
 
@@ -238,7 +247,7 @@ function block_core_image_print_lightbox_overlay() {
238
247
  }
239
248
 
240
249
  echo <<<HTML
241
- <div
250
+ <div
242
251
  class="wp-lightbox-overlay zoom"
243
252
  data-wp-interactive="core/image"
244
253
  data-wp-context='{}'
@@ -278,6 +287,8 @@ HTML;
278
287
 
279
288
  /**
280
289
  * Registers the `core/image` block on server.
290
+ *
291
+ * @since 5.9.0
281
292
  */
282
293
  function register_block_core_image() {
283
294
  register_block_type_from_metadata(
@@ -2,6 +2,6 @@
2
2
  @include caption-style-theme();
3
3
  }
4
4
 
5
- .wp-block-image {
5
+ :where(.wp-block-image) {
6
6
  margin: 0 0 1em 0;
7
7
  }
@@ -36,6 +36,8 @@ function wp_latest_comments_draft_or_post_title( $post = 0 ) {
36
36
  /**
37
37
  * Renders the `core/latest-comments` block on server.
38
38
  *
39
+ * @since 5.1.0
40
+ *
39
41
  * @param array $attributes The block attributes.
40
42
  *
41
43
  * @return string Returns the post content with latest comments added.
@@ -145,6 +147,8 @@ function render_block_core_latest_comments( $attributes = array() ) {
145
147
 
146
148
  /**
147
149
  * Registers the `core/latest-comments` block.
150
+ *
151
+ * @since 5.3.0
148
152
  */
149
153
  function register_block_core_latest_comments() {
150
154
  register_block_type_from_metadata(
@@ -18,6 +18,8 @@ $block_core_latest_posts_excerpt_length = 0;
18
18
  * Callback for the excerpt_length filter used by
19
19
  * the Latest Posts block at render time.
20
20
  *
21
+ * @since 5.4.0
22
+ *
21
23
  * @return int Returns the global $block_core_latest_posts_excerpt_length variable
22
24
  * to allow the excerpt_length filter respect the Latest Block setting.
23
25
  */
@@ -29,6 +31,8 @@ function block_core_latest_posts_get_excerpt_length() {
29
31
  /**
30
32
  * Renders the `core/latest-posts` block on server.
31
33
  *
34
+ * @since 5.0.0
35
+ *
32
36
  * @param array $attributes The block attributes.
33
37
  *
34
38
  * @return string Returns the post content with latest posts added.
@@ -218,6 +222,8 @@ function render_block_core_latest_posts( $attributes ) {
218
222
 
219
223
  /**
220
224
  * Registers the `core/latest-posts` block on server.
225
+ *
226
+ * @since 5.0.0
221
227
  */
222
228
  function register_block_core_latest_posts() {
223
229
  register_block_type_from_metadata(
@@ -241,6 +247,8 @@ add_action( 'init', 'register_block_core_latest_posts' );
241
247
  * TODO: Remove when and if the bottom client-side deprecation for this block
242
248
  * is removed.
243
249
  *
250
+ * @since 5.5.0
251
+ *
244
252
  * @param array $block A single parsed block object.
245
253
  *
246
254
  * @return array The migrated block object.
@@ -8,6 +8,8 @@
8
8
  /**
9
9
  * Renders the `core/loginout` block on server.
10
10
  *
11
+ * @since 5.8.0
12
+ *
11
13
  * @param array $attributes The block attributes.
12
14
  *
13
15
  * @return string Returns the login-out link or form.
@@ -39,6 +41,8 @@ function render_block_core_loginout( $attributes ) {
39
41
 
40
42
  /**
41
43
  * Registers the `core/loginout` block on server.
44
+ *
45
+ * @since 5.8.0
42
46
  */
43
47
  function register_block_core_loginout() {
44
48
  register_block_type_from_metadata(
@@ -92,8 +92,13 @@
92
92
  },
93
93
  "allowedBlocks": {
94
94
  "type": "array"
95
+ },
96
+ "useFeaturedImage": {
97
+ "type": "boolean",
98
+ "default": false
95
99
  }
96
100
  },
101
+ "usesContext": [ "postId", "postType" ],
97
102
  "supports": {
98
103
  "anchor": true,
99
104
  "align": [ "wide", "full" ],
@@ -31,7 +31,7 @@ import {
31
31
  } from '@wordpress/components';
32
32
  import { isBlobURL, getBlobTypeByURL } from '@wordpress/blob';
33
33
  import { pullLeft, pullRight } from '@wordpress/icons';
34
- import { store as coreStore } from '@wordpress/core-data';
34
+ import { useEntityProp, store as coreStore } from '@wordpress/core-data';
35
35
 
36
36
  /**
37
37
  * Internal dependencies
@@ -127,7 +127,12 @@ function attributesFromMedia( {
127
127
  };
128
128
  }
129
129
 
130
- function MediaTextEdit( { attributes, isSelected, setAttributes } ) {
130
+ function MediaTextEdit( {
131
+ attributes,
132
+ isSelected,
133
+ setAttributes,
134
+ context: { postId, postType },
135
+ } ) {
131
136
  const {
132
137
  focalPoint,
133
138
  href,
@@ -145,9 +150,42 @@ function MediaTextEdit( { attributes, isSelected, setAttributes } ) {
145
150
  rel,
146
151
  verticalAlignment,
147
152
  allowedBlocks,
153
+ useFeaturedImage,
148
154
  } = attributes;
149
155
  const mediaSizeSlug = attributes.mediaSizeSlug || DEFAULT_MEDIA_SIZE_SLUG;
150
156
 
157
+ const [ featuredImage ] = useEntityProp(
158
+ 'postType',
159
+ postType,
160
+ 'featured_media',
161
+ postId
162
+ );
163
+
164
+ const featuredImageMedia = useSelect(
165
+ ( select ) =>
166
+ featuredImage &&
167
+ select( coreStore ).getMedia( featuredImage, { context: 'view' } ),
168
+ [ featuredImage ]
169
+ );
170
+
171
+ const featuredImageURL = useFeaturedImage
172
+ ? featuredImageMedia?.source_url
173
+ : '';
174
+ const featuredImageAlt = useFeaturedImage
175
+ ? featuredImageMedia?.alt_text
176
+ : '';
177
+
178
+ const toggleUseFeaturedImage = () => {
179
+ setAttributes( {
180
+ imageFill: false,
181
+ mediaType: 'image',
182
+ mediaId: undefined,
183
+ mediaUrl: undefined,
184
+ mediaAlt: undefined,
185
+ useFeaturedImage: ! useFeaturedImage,
186
+ } );
187
+ };
188
+
151
189
  const { imageSizes, image } = useSelect(
152
190
  ( select ) => {
153
191
  const { getSettings } = select( blockEditorStore );
@@ -261,25 +299,30 @@ function MediaTextEdit( { attributes, isSelected, setAttributes } ) {
261
299
  }
262
300
  />
263
301
  ) }
264
- { imageFill && mediaUrl && mediaType === 'image' && (
265
- <FocalPointPicker
266
- __nextHasNoMarginBottom
267
- __next40pxDefaultSize
268
- label={ __( 'Focal point' ) }
269
- url={ mediaUrl }
270
- value={ focalPoint }
271
- onChange={ ( value ) =>
272
- setAttributes( { focalPoint: value } )
273
- }
274
- onDragStart={ imperativeFocalPointPreview }
275
- onDrag={ imperativeFocalPointPreview }
276
- />
277
- ) }
278
- { mediaType === 'image' && (
302
+ { imageFill &&
303
+ ( mediaUrl || featuredImageURL ) &&
304
+ mediaType === 'image' && (
305
+ <FocalPointPicker
306
+ __nextHasNoMarginBottom
307
+ label={ __( 'Focal point' ) }
308
+ url={
309
+ useFeaturedImage && featuredImageURL
310
+ ? featuredImageURL
311
+ : mediaUrl
312
+ }
313
+ value={ focalPoint }
314
+ onChange={ ( value ) =>
315
+ setAttributes( { focalPoint: value } )
316
+ }
317
+ onDragStart={ imperativeFocalPointPreview }
318
+ onDrag={ imperativeFocalPointPreview }
319
+ />
320
+ ) }
321
+ { mediaType === 'image' && ( mediaUrl || featuredImageURL ) && (
279
322
  <TextareaControl
280
323
  __nextHasNoMarginBottom
281
324
  label={ __( 'Alternative text' ) }
282
- value={ mediaAlt }
325
+ value={ mediaAlt || featuredImageAlt }
283
326
  onChange={ onMediaAltChange }
284
327
  help={
285
328
  <>
@@ -353,7 +396,11 @@ function MediaTextEdit( { attributes, isSelected, setAttributes } ) {
353
396
  onChangeUrl={ onSetHref }
354
397
  linkDestination={ linkDestination }
355
398
  mediaType={ mediaType }
356
- mediaUrl={ image && image.source_url }
399
+ mediaUrl={
400
+ useFeaturedImage && featuredImageURL
401
+ ? featuredImageURL
402
+ : image && image.source_url
403
+ }
357
404
  mediaLink={ image && image.link }
358
405
  linkTarget={ linkTarget }
359
406
  linkClass={ linkClass }
@@ -370,6 +417,7 @@ function MediaTextEdit( { attributes, isSelected, setAttributes } ) {
370
417
  commitWidthChange={ commitWidthChange }
371
418
  ref={ refMediaContainer }
372
419
  enableResize={ blockEditingMode === 'default' }
420
+ toggleUseFeaturedImage={ toggleUseFeaturedImage }
373
421
  { ...{
374
422
  focalPoint,
375
423
  imageFill,
@@ -381,6 +429,9 @@ function MediaTextEdit( { attributes, isSelected, setAttributes } ) {
381
429
  mediaType,
382
430
  mediaUrl,
383
431
  mediaWidth,
432
+ useFeaturedImage,
433
+ featuredImageURL,
434
+ featuredImageAlt,
384
435
  } }
385
436
  />
386
437
  { mediaPosition !== 'right' && <div { ...innerBlocksProps } /> }
@@ -26,7 +26,8 @@
26
26
  width: 100% !important;
27
27
  }
28
28
 
29
- .wp-block-media-text.is-image-fill .editor-media-container__resizer {
29
+ .wp-block-media-text.is-image-fill .editor-media-container__resizer,
30
+ .wp-block-media-text.is-image-fill .components-placeholder.has-illustration {
30
31
  // The resizer sets an inline height but for the image fill we set it to full height.
31
32
  height: 100% !important;
32
33
  }
@@ -34,3 +35,8 @@
34
35
  .wp-block-media-text > .block-editor-block-list__layout > .block-editor-block-list__block {
35
36
  max-width: unset;
36
37
  }
38
+
39
+ /* Make the featured image placeholder the same height as the media selection area. */
40
+ .wp-block-media-text--placeholder-image {
41
+ min-height: 205px;
42
+ }
@@ -0,0 +1,70 @@
1
+ <?php
2
+ /**
3
+ * Server-side rendering of the `core/media-text` block.
4
+ *
5
+ * @package WordPress
6
+ */
7
+
8
+ /**
9
+ * Renders the `core/media-text` block on server.
10
+ *
11
+ * @since 6.6.0
12
+ *
13
+ * @param array $attributes The block attributes.
14
+ * @param string $content The block rendered content.
15
+ *
16
+ * @return string Returns the Media & Text block markup, if useFeaturedImage is true.
17
+ */
18
+ function render_block_core_media_text( $attributes, $content ) {
19
+ if ( false === $attributes['useFeaturedImage'] ) {
20
+ return $content;
21
+ }
22
+
23
+ if ( in_the_loop() ) {
24
+ update_post_thumbnail_cache();
25
+ }
26
+
27
+ $current_featured_image = get_the_post_thumbnail_url();
28
+ if ( ! $current_featured_image ) {
29
+ return $content;
30
+ }
31
+
32
+ $image_tag = '<figure class="wp-block-media-text__media"><img>';
33
+ $content = preg_replace( '/<figure\s+class="wp-block-media-text__media">/', $image_tag, $content );
34
+
35
+ $processor = new WP_HTML_Tag_Processor( $content );
36
+ if ( isset( $attributes['imageFill'] ) && $attributes['imageFill'] ) {
37
+ $position = '50% 50%';
38
+ if ( isset( $attributes['focalPoint'] ) ) {
39
+ $position = round( $attributes['focalPoint']['x'] * 100 ) . '% ' . round( $attributes['focalPoint']['y'] * 100 ) . '%';
40
+ }
41
+ $processor->next_tag( 'figure' );
42
+ $processor->set_attribute( 'style', 'background-image:url(' . esc_url( $current_featured_image ) . ');background-position:' . $position . ';' );
43
+ }
44
+ $processor->next_tag( 'img' );
45
+ $media_size_slug = 'full';
46
+ if ( isset( $attributes['mediaSizeSlug'] ) ) {
47
+ $media_size_slug = $attributes['mediaSizeSlug'];
48
+ }
49
+ $processor->set_attribute( 'src', esc_url( $current_featured_image ) );
50
+ $processor->set_attribute( 'class', 'wp-image-' . get_post_thumbnail_id() . ' size-' . $media_size_slug );
51
+
52
+ $content = $processor->get_updated_html();
53
+
54
+ return $content;
55
+ }
56
+
57
+ /**
58
+ * Registers the `core/media-text` block renderer on server.
59
+ *
60
+ * @since 6.6.0
61
+ */
62
+ function register_block_core_media_text() {
63
+ register_block_type_from_metadata(
64
+ __DIR__ . '/media-text',
65
+ array(
66
+ 'render_callback' => 'render_block_core_media_text',
67
+ )
68
+ );
69
+ }
70
+ add_action( 'init', 'register_block_core_media_text' );
@@ -6,7 +6,7 @@ import classnames from 'classnames';
6
6
  /**
7
7
  * WordPress dependencies
8
8
  */
9
- import { ResizableBox, Spinner } from '@wordpress/components';
9
+ import { ResizableBox, Spinner, Placeholder } from '@wordpress/components';
10
10
  import {
11
11
  BlockControls,
12
12
  BlockIcon,
@@ -56,21 +56,39 @@ const ResizableBoxContainer = forwardRef(
56
56
  }
57
57
  );
58
58
 
59
- function ToolbarEditButton( { mediaId, mediaUrl, onSelectMedia } ) {
59
+ function ToolbarEditButton( {
60
+ mediaId,
61
+ mediaUrl,
62
+ onSelectMedia,
63
+ toggleUseFeaturedImage,
64
+ useFeaturedImage,
65
+ featuredImageURL,
66
+ } ) {
60
67
  return (
61
68
  <BlockControls group="other">
62
69
  <MediaReplaceFlow
63
70
  mediaId={ mediaId }
64
- mediaURL={ mediaUrl }
71
+ mediaUrl={
72
+ useFeaturedImage && featuredImageURL
73
+ ? featuredImageURL
74
+ : mediaUrl
75
+ }
65
76
  allowedTypes={ ALLOWED_MEDIA_TYPES }
66
77
  accept="image/*,video/*"
67
78
  onSelect={ onSelectMedia }
79
+ onToggleFeaturedImage={ toggleUseFeaturedImage }
80
+ useFeaturedImage={ useFeaturedImage }
68
81
  />
69
82
  </BlockControls>
70
83
  );
71
84
  }
72
85
 
73
- function PlaceholderContainer( { className, mediaUrl, onSelectMedia } ) {
86
+ function PlaceholderContainer( {
87
+ className,
88
+ mediaUrl,
89
+ onSelectMedia,
90
+ toggleUseFeaturedImage,
91
+ } ) {
74
92
  const { createErrorNotice } = useDispatch( noticesStore );
75
93
 
76
94
  const onUploadError = ( message ) => {
@@ -86,6 +104,7 @@ function PlaceholderContainer( { className, mediaUrl, onSelectMedia } ) {
86
104
  className={ className }
87
105
  onSelect={ onSelectMedia }
88
106
  accept="image/*,video/*"
107
+ onToggleFeaturedImage={ toggleUseFeaturedImage }
89
108
  allowedTypes={ ALLOWED_MEDIA_TYPES }
90
109
  onError={ onUploadError }
91
110
  disableMediaButtons={ mediaUrl }
@@ -110,13 +129,17 @@ function MediaContainer( props, ref ) {
110
129
  onSelectMedia,
111
130
  onWidthChange,
112
131
  enableResize,
132
+ toggleUseFeaturedImage,
133
+ useFeaturedImage,
134
+ featuredImageURL,
135
+ featuredImageAlt,
113
136
  } = props;
114
137
 
115
138
  const isTemporaryMedia = ! mediaId && isBlobURL( mediaUrl );
116
139
 
117
140
  const { toggleSelection } = useDispatch( blockEditorStore );
118
141
 
119
- if ( mediaUrl ) {
142
+ if ( mediaUrl || featuredImageURL || useFeaturedImage ) {
120
143
  const onResizeStart = () => {
121
144
  toggleSelection( false );
122
145
  };
@@ -134,11 +157,16 @@ function MediaContainer( props, ref ) {
134
157
 
135
158
  const backgroundStyles =
136
159
  mediaType === 'image' && imageFill
137
- ? imageFillStyles( mediaUrl, focalPoint )
160
+ ? imageFillStyles( mediaUrl || featuredImageURL, focalPoint )
138
161
  : {};
139
162
 
140
163
  const mediaTypeRenderers = {
141
- image: () => <img src={ mediaUrl } alt={ mediaAlt } />,
164
+ image: () =>
165
+ useFeaturedImage && featuredImageURL ? (
166
+ <img src={ featuredImageURL } alt={ featuredImageAlt } />
167
+ ) : (
168
+ mediaUrl && <img src={ mediaUrl } alt={ mediaAlt } />
169
+ ),
142
170
  video: () => <video controls src={ mediaUrl } />,
143
171
  };
144
172
 
@@ -165,12 +193,24 @@ function MediaContainer( props, ref ) {
165
193
  >
166
194
  <ToolbarEditButton
167
195
  onSelectMedia={ onSelectMedia }
168
- mediaUrl={ mediaUrl }
196
+ mediaUrl={
197
+ useFeaturedImage && featuredImageURL
198
+ ? featuredImageURL
199
+ : mediaUrl
200
+ }
169
201
  mediaId={ mediaId }
202
+ toggleUseFeaturedImage={ toggleUseFeaturedImage }
203
+ useFeaturedImage={ useFeaturedImage }
170
204
  />
171
205
  { ( mediaTypeRenderers[ mediaType ] || noop )() }
172
206
  { isTemporaryMedia && <Spinner /> }
173
- <PlaceholderContainer { ...props } />
207
+ { ! useFeaturedImage && <PlaceholderContainer { ...props } /> }
208
+ { ! featuredImageURL && useFeaturedImage && (
209
+ <Placeholder
210
+ className="wp-block-media-text--placeholder-image"
211
+ withIllustration
212
+ />
213
+ ) }
174
214
  </ResizableBoxContainer>
175
215
  );
176
216
  }
@@ -42,13 +42,13 @@ export default function save( { attributes } ) {
42
42
  [ `size-${ mediaSizeSlug }` ]: mediaId && mediaType === 'image',
43
43
  } );
44
44
 
45
- let image = (
45
+ let image = mediaUrl ? (
46
46
  <img
47
47
  src={ mediaUrl }
48
48
  alt={ mediaAlt }
49
49
  className={ imageClasses || null }
50
50
  />
51
- );
51
+ ) : null;
52
52
 
53
53
  if ( href ) {
54
54
  image = (