@wordpress/block-library 9.6.1 → 9.7.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 (310) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/build/audio/edit.js +2 -1
  3. package/build/audio/edit.js.map +1 -1
  4. package/build/block/edit.js +3 -5
  5. package/build/block/edit.js.map +1 -1
  6. package/build/button/edit.js +1 -1
  7. package/build/button/edit.js.map +1 -1
  8. package/build/categories/index.js +1 -0
  9. package/build/categories/index.js.map +1 -1
  10. package/build/comment-edit-link/index.js +13 -2
  11. package/build/comment-edit-link/index.js.map +1 -1
  12. package/build/comment-reply-link/index.js +13 -2
  13. package/build/comment-reply-link/index.js.map +1 -1
  14. package/build/comments/edit/comments-legacy.js +4 -1
  15. package/build/comments/edit/comments-legacy.js.map +1 -1
  16. package/build/cover/edit/block-controls.js +4 -2
  17. package/build/cover/edit/block-controls.js.map +1 -1
  18. package/build/cover/edit/index.js +2 -1
  19. package/build/cover/edit/index.js.map +1 -1
  20. package/build/cover/edit/inspector-controls.js +4 -12
  21. package/build/cover/edit/inspector-controls.js.map +1 -1
  22. package/build/details/index.js +3 -1
  23. package/build/details/index.js.map +1 -1
  24. package/build/details/transforms.js +24 -0
  25. package/build/details/transforms.js.map +1 -0
  26. package/build/embed/embed-placeholder.js +8 -2
  27. package/build/embed/embed-placeholder.js.map +1 -1
  28. package/build/file/edit.js +12 -1
  29. package/build/file/edit.js.map +1 -1
  30. package/build/freeform/edit.js +4 -4
  31. package/build/freeform/edit.js.map +1 -1
  32. package/build/freeform/modal.js +12 -3
  33. package/build/freeform/modal.js.map +1 -1
  34. package/build/home-link/edit.js +3 -9
  35. package/build/home-link/edit.js.map +1 -1
  36. package/build/image/edit.js +44 -34
  37. package/build/image/edit.js.map +1 -1
  38. package/build/image/image.js +22 -10
  39. package/build/image/image.js.map +1 -1
  40. package/build/media-text/deprecated.js +144 -3
  41. package/build/media-text/deprecated.js.map +1 -1
  42. package/build/media-text/edit.js +5 -5
  43. package/build/media-text/edit.js.map +1 -1
  44. package/build/media-text/image-fill.js +12 -0
  45. package/build/media-text/image-fill.js.map +1 -0
  46. package/build/media-text/media-container.js +21 -18
  47. package/build/media-text/media-container.js.map +1 -1
  48. package/build/media-text/media-container.native.js +0 -7
  49. package/build/media-text/media-container.native.js.map +1 -1
  50. package/build/media-text/save.js +5 -6
  51. package/build/media-text/save.js.map +1 -1
  52. package/build/missing/edit.js +6 -3
  53. package/build/missing/edit.js.map +1 -1
  54. package/build/navigation/edit/deleted-navigation-warning.js +4 -1
  55. package/build/navigation/edit/deleted-navigation-warning.js.map +1 -1
  56. package/build/navigation/edit/index.js +4 -1
  57. package/build/navigation/edit/index.js.map +1 -1
  58. package/build/navigation/edit/navigation-menu-delete-control.js +4 -1
  59. package/build/navigation/edit/navigation-menu-delete-control.js.map +1 -1
  60. package/build/navigation/edit/placeholder/index.js +4 -1
  61. package/build/navigation/edit/placeholder/index.js.map +1 -1
  62. package/build/navigation/edit/responsive-wrapper.js +8 -2
  63. package/build/navigation/edit/responsive-wrapper.js.map +1 -1
  64. package/build/navigation/edit/unsaved-inner-blocks.js +4 -4
  65. package/build/navigation/edit/unsaved-inner-blocks.js.map +1 -1
  66. package/build/navigation-link/link-ui.js +5 -2
  67. package/build/navigation-link/link-ui.js.map +1 -1
  68. package/build/page-list/convert-to-links-modal.js +8 -2
  69. package/build/page-list/convert-to-links-modal.js.map +1 -1
  70. package/build/page-list/edit.js +7 -2
  71. package/build/page-list/edit.js.map +1 -1
  72. package/build/post-comments-form/form.js +4 -1
  73. package/build/post-comments-form/form.js.map +1 -1
  74. package/build/post-featured-image/dimension-controls.js +6 -8
  75. package/build/post-featured-image/dimension-controls.js.map +1 -1
  76. package/build/post-featured-image/edit.js +5 -5
  77. package/build/post-featured-image/edit.js.map +1 -1
  78. package/build/query/edit/enhanced-pagination-modal.js +4 -1
  79. package/build/query/edit/enhanced-pagination-modal.js.map +1 -1
  80. package/build/query/edit/query-placeholder.js +8 -2
  81. package/build/query/edit/query-placeholder.js.map +1 -1
  82. package/build/site-logo/edit.js +15 -15
  83. package/build/site-logo/edit.js.map +1 -1
  84. package/build/social-link/edit.js +4 -1
  85. package/build/social-link/edit.js.map +1 -1
  86. package/build/social-links/edit.js +10 -9
  87. package/build/social-links/edit.js.map +1 -1
  88. package/build/template-part/edit/advanced-controls.js.map +1 -1
  89. package/build/template-part/edit/index.js +1 -1
  90. package/build/template-part/edit/index.js.map +1 -1
  91. package/build/template-part/edit/placeholder.js +8 -2
  92. package/build/template-part/edit/placeholder.js.map +1 -1
  93. package/build/utils/hooks.js +10 -10
  94. package/build/utils/hooks.js.map +1 -1
  95. package/build/video/edit.js +22 -14
  96. package/build/video/edit.js.map +1 -1
  97. package/build/video/tracks-editor.js +12 -3
  98. package/build/video/tracks-editor.js.map +1 -1
  99. package/build-module/audio/edit.js +2 -1
  100. package/build-module/audio/edit.js.map +1 -1
  101. package/build-module/block/edit.js +4 -6
  102. package/build-module/block/edit.js.map +1 -1
  103. package/build-module/button/edit.js +1 -1
  104. package/build-module/button/edit.js.map +1 -1
  105. package/build-module/categories/index.js +1 -0
  106. package/build-module/categories/index.js.map +1 -1
  107. package/build-module/comment-edit-link/index.js +13 -2
  108. package/build-module/comment-edit-link/index.js.map +1 -1
  109. package/build-module/comment-reply-link/index.js +13 -2
  110. package/build-module/comment-reply-link/index.js.map +1 -1
  111. package/build-module/comments/edit/comments-legacy.js +4 -1
  112. package/build-module/comments/edit/comments-legacy.js.map +1 -1
  113. package/build-module/cover/edit/block-controls.js +4 -2
  114. package/build-module/cover/edit/block-controls.js.map +1 -1
  115. package/build-module/cover/edit/index.js +2 -1
  116. package/build-module/cover/edit/index.js.map +1 -1
  117. package/build-module/cover/edit/inspector-controls.js +5 -13
  118. package/build-module/cover/edit/inspector-controls.js.map +1 -1
  119. package/build-module/details/index.js +3 -1
  120. package/build-module/details/index.js.map +1 -1
  121. package/build-module/details/transforms.js +18 -0
  122. package/build-module/details/transforms.js.map +1 -0
  123. package/build-module/embed/embed-placeholder.js +8 -2
  124. package/build-module/embed/embed-placeholder.js.map +1 -1
  125. package/build-module/file/edit.js +12 -1
  126. package/build-module/file/edit.js.map +1 -1
  127. package/build-module/freeform/edit.js +4 -4
  128. package/build-module/freeform/edit.js.map +1 -1
  129. package/build-module/freeform/modal.js +12 -3
  130. package/build-module/freeform/modal.js.map +1 -1
  131. package/build-module/home-link/edit.js +3 -9
  132. package/build-module/home-link/edit.js.map +1 -1
  133. package/build-module/image/edit.js +45 -34
  134. package/build-module/image/edit.js.map +1 -1
  135. package/build-module/image/image.js +23 -11
  136. package/build-module/image/image.js.map +1 -1
  137. package/build-module/media-text/deprecated.js +144 -3
  138. package/build-module/media-text/deprecated.js.map +1 -1
  139. package/build-module/media-text/edit.js +5 -5
  140. package/build-module/media-text/edit.js.map +1 -1
  141. package/build-module/media-text/image-fill.js +6 -0
  142. package/build-module/media-text/image-fill.js.map +1 -0
  143. package/build-module/media-text/media-container.js +21 -17
  144. package/build-module/media-text/media-container.js.map +1 -1
  145. package/build-module/media-text/media-container.native.js +0 -1
  146. package/build-module/media-text/media-container.native.js.map +1 -1
  147. package/build-module/media-text/save.js +5 -6
  148. package/build-module/media-text/save.js.map +1 -1
  149. package/build-module/missing/edit.js +6 -3
  150. package/build-module/missing/edit.js.map +1 -1
  151. package/build-module/navigation/edit/deleted-navigation-warning.js +4 -1
  152. package/build-module/navigation/edit/deleted-navigation-warning.js.map +1 -1
  153. package/build-module/navigation/edit/index.js +4 -1
  154. package/build-module/navigation/edit/index.js.map +1 -1
  155. package/build-module/navigation/edit/navigation-menu-delete-control.js +4 -1
  156. package/build-module/navigation/edit/navigation-menu-delete-control.js.map +1 -1
  157. package/build-module/navigation/edit/placeholder/index.js +4 -1
  158. package/build-module/navigation/edit/placeholder/index.js.map +1 -1
  159. package/build-module/navigation/edit/responsive-wrapper.js +8 -2
  160. package/build-module/navigation/edit/responsive-wrapper.js.map +1 -1
  161. package/build-module/navigation/edit/unsaved-inner-blocks.js +4 -4
  162. package/build-module/navigation/edit/unsaved-inner-blocks.js.map +1 -1
  163. package/build-module/navigation-link/link-ui.js +7 -4
  164. package/build-module/navigation-link/link-ui.js.map +1 -1
  165. package/build-module/page-list/convert-to-links-modal.js +8 -2
  166. package/build-module/page-list/convert-to-links-modal.js.map +1 -1
  167. package/build-module/page-list/edit.js +7 -2
  168. package/build-module/page-list/edit.js.map +1 -1
  169. package/build-module/post-comments-form/form.js +4 -1
  170. package/build-module/post-comments-form/form.js.map +1 -1
  171. package/build-module/post-featured-image/dimension-controls.js +6 -8
  172. package/build-module/post-featured-image/dimension-controls.js.map +1 -1
  173. package/build-module/post-featured-image/edit.js +6 -6
  174. package/build-module/post-featured-image/edit.js.map +1 -1
  175. package/build-module/query/edit/enhanced-pagination-modal.js +4 -1
  176. package/build-module/query/edit/enhanced-pagination-modal.js.map +1 -1
  177. package/build-module/query/edit/query-placeholder.js +8 -2
  178. package/build-module/query/edit/query-placeholder.js.map +1 -1
  179. package/build-module/site-logo/edit.js +16 -16
  180. package/build-module/site-logo/edit.js.map +1 -1
  181. package/build-module/social-link/edit.js +4 -1
  182. package/build-module/social-link/edit.js.map +1 -1
  183. package/build-module/social-links/edit.js +11 -10
  184. package/build-module/social-links/edit.js.map +1 -1
  185. package/build-module/template-part/edit/advanced-controls.js.map +1 -1
  186. package/build-module/template-part/edit/index.js +1 -1
  187. package/build-module/template-part/edit/index.js.map +1 -1
  188. package/build-module/template-part/edit/placeholder.js +8 -2
  189. package/build-module/template-part/edit/placeholder.js.map +1 -1
  190. package/build-module/utils/hooks.js +10 -10
  191. package/build-module/utils/hooks.js.map +1 -1
  192. package/build-module/video/edit.js +22 -15
  193. package/build-module/video/edit.js.map +1 -1
  194. package/build-module/video/tracks-editor.js +12 -3
  195. package/build-module/video/tracks-editor.js.map +1 -1
  196. package/build-style/button/editor-rtl.css +0 -4
  197. package/build-style/button/editor.css +0 -4
  198. package/build-style/buttons/editor-rtl.css +0 -3
  199. package/build-style/buttons/editor.css +0 -3
  200. package/build-style/comment-edit-link/style-rtl.css +94 -0
  201. package/build-style/comment-edit-link/style.css +94 -0
  202. package/build-style/comment-reply-link/style-rtl.css +94 -0
  203. package/build-style/comment-reply-link/style.css +94 -0
  204. package/build-style/comments-pagination/editor-rtl.css +2 -2
  205. package/build-style/comments-pagination/editor.css +2 -2
  206. package/build-style/cover/editor-rtl.css +0 -6
  207. package/build-style/cover/editor.css +0 -6
  208. package/build-style/editor-rtl.css +24 -68
  209. package/build-style/editor.css +24 -70
  210. package/build-style/group/editor-rtl.css +0 -1
  211. package/build-style/group/editor.css +0 -1
  212. package/build-style/image/editor-rtl.css +0 -1
  213. package/build-style/image/editor.css +0 -1
  214. package/build-style/media-text/editor-rtl.css +3 -1
  215. package/build-style/media-text/editor.css +3 -1
  216. package/build-style/media-text/style-rtl.css +20 -0
  217. package/build-style/media-text/style.css +20 -0
  218. package/build-style/navigation/editor-rtl.css +0 -1
  219. package/build-style/navigation/editor.css +0 -1
  220. package/build-style/post-featured-image/style-rtl.css +1 -1
  221. package/build-style/post-featured-image/style.css +1 -1
  222. package/build-style/query-pagination/editor-rtl.css +2 -16
  223. package/build-style/query-pagination/editor.css +2 -18
  224. package/build-style/query-pagination/style-rtl.css +0 -11
  225. package/build-style/query-pagination/style.css +0 -13
  226. package/build-style/site-title/editor-rtl.css +0 -4
  227. package/build-style/site-title/editor.css +0 -4
  228. package/build-style/social-links/editor-rtl.css +17 -0
  229. package/build-style/social-links/editor.css +17 -0
  230. package/build-style/style-rtl.css +29 -12
  231. package/build-style/style.css +29 -14
  232. package/build-style/video/editor-rtl.css +0 -29
  233. package/build-style/video/editor.css +0 -29
  234. package/package.json +35 -35
  235. package/src/audio/edit.js +1 -0
  236. package/src/block/edit.js +6 -4
  237. package/src/button/edit.js +1 -1
  238. package/src/button/editor.scss +0 -5
  239. package/src/buttons/editor.scss +0 -6
  240. package/src/categories/block.json +1 -0
  241. package/src/categories/index.php +13 -2
  242. package/src/comment-edit-link/block.json +13 -2
  243. package/src/comment-edit-link/style.scss +4 -0
  244. package/src/comment-reply-link/block.json +13 -2
  245. package/src/comment-reply-link/style.scss +4 -0
  246. package/src/comments/edit/comments-legacy.js +2 -0
  247. package/src/comments-pagination/editor.scss +1 -1
  248. package/src/cover/edit/block-controls.js +2 -0
  249. package/src/cover/edit/index.js +1 -0
  250. package/src/cover/edit/inspector-controls.js +3 -15
  251. package/src/cover/editor.scss +0 -5
  252. package/src/cover/test/edit.js +30 -26
  253. package/src/details/index.js +2 -0
  254. package/src/details/transforms.js +26 -0
  255. package/src/embed/embed-placeholder.js +12 -2
  256. package/src/file/edit.js +11 -0
  257. package/src/freeform/edit.js +4 -4
  258. package/src/freeform/editor.scss +1 -1
  259. package/src/freeform/modal.js +10 -1
  260. package/src/gallery/editor.scss +1 -1
  261. package/src/group/editor.scss +0 -1
  262. package/src/home-link/edit.js +4 -7
  263. package/src/image/edit.js +42 -30
  264. package/src/image/editor.scss +0 -3
  265. package/src/image/image.js +75 -53
  266. package/src/media-text/deprecated.js +159 -3
  267. package/src/media-text/edit.js +5 -5
  268. package/src/media-text/editor.scss +3 -1
  269. package/src/media-text/image-fill.js +11 -0
  270. package/src/media-text/index.php +53 -43
  271. package/src/media-text/media-container.js +25 -25
  272. package/src/media-text/media-container.native.js +0 -2
  273. package/src/media-text/save.js +9 -13
  274. package/src/media-text/style.scss +21 -0
  275. package/src/media-text/test/image-fill.js +19 -0
  276. package/src/missing/edit.js +9 -3
  277. package/src/navigation/edit/deleted-navigation-warning.js +8 -1
  278. package/src/navigation/edit/index.js +2 -0
  279. package/src/navigation/edit/navigation-menu-delete-control.js +2 -0
  280. package/src/navigation/edit/placeholder/index.js +2 -0
  281. package/src/navigation/edit/responsive-wrapper.js +4 -0
  282. package/src/navigation/edit/unsaved-inner-blocks.js +4 -4
  283. package/src/navigation/editor.scss +6 -3
  284. package/src/navigation-link/link-ui.js +5 -3
  285. package/src/page-list/convert-to-links-modal.js +8 -1
  286. package/src/page-list/edit.js +7 -1
  287. package/src/page-list/index.php +3 -1
  288. package/src/post-comments-form/form.js +2 -0
  289. package/src/post-featured-image/dimension-controls.js +4 -4
  290. package/src/post-featured-image/edit.js +4 -6
  291. package/src/post-featured-image/style.scss +1 -1
  292. package/src/query/edit/enhanced-pagination-modal.js +6 -1
  293. package/src/query/edit/query-placeholder.js +4 -0
  294. package/src/query-pagination/editor.scss +1 -21
  295. package/src/query-pagination/style.scss +0 -15
  296. package/src/site-logo/edit.js +13 -20
  297. package/src/site-title/editor.scss +0 -4
  298. package/src/social-link/edit.js +2 -0
  299. package/src/social-links/edit.js +17 -10
  300. package/src/social-links/editor.scss +24 -5
  301. package/src/style.scss +2 -0
  302. package/src/tag-cloud/index.php +7 -2
  303. package/src/template-part/edit/advanced-controls.js +0 -1
  304. package/src/template-part/edit/index.js +12 -10
  305. package/src/template-part/edit/placeholder.js +8 -1
  306. package/src/utils/hooks.js +11 -11
  307. package/src/video/edit.js +26 -21
  308. package/src/video/editor.scss +0 -45
  309. package/src/video/tracks-editor.js +6 -0
  310. package/src/media-text/test/media-container.js +0 -24
@@ -29,15 +29,32 @@ function render_block_core_media_text( $attributes, $content ) {
29
29
  return $content;
30
30
  }
31
31
 
32
+ $has_media_on_right = isset( $attributes['mediaPosition'] ) && 'right' === $attributes['mediaPosition'];
33
+ $image_fill = isset( $attributes['imageFill'] ) && $attributes['imageFill'];
34
+ $focal_point = isset( $attributes['focalPoint'] ) ? round( $attributes['focalPoint']['x'] * 100 ) . '% ' . round( $attributes['focalPoint']['y'] * 100 ) . '%' : '50% 50%';
35
+ $unique_id = 'wp-block-media-text__media-' . wp_unique_id();
36
+
37
+ $block_tag_processor = new WP_HTML_Tag_Processor( $content );
38
+ $block_query = array(
39
+ 'tag_name' => 'div',
40
+ 'class_name' => 'wp-block-media-text',
41
+ );
42
+
43
+ while ( $block_tag_processor->next_tag( $block_query ) ) {
44
+ if ( $image_fill ) {
45
+ // The markup below does not work with the deprecated `is-image-fill` class.
46
+ $block_tag_processor->remove_class( 'is-image-fill' );
47
+ $block_tag_processor->add_class( 'is-image-fill-element' );
48
+ }
49
+ }
50
+
51
+ $content = $block_tag_processor->get_updated_html();
52
+
32
53
  $media_tag_processor = new WP_HTML_Tag_Processor( $content );
33
54
  $wrapping_figure_query = array(
34
55
  'tag_name' => 'figure',
35
56
  'class_name' => 'wp-block-media-text__media',
36
57
  );
37
- $has_media_on_right = isset( $attributes['mediaPosition'] ) && 'right' === $attributes['mediaPosition'];
38
- $image_fill = isset( $attributes['imageFill'] ) && $attributes['imageFill'];
39
- $focal_point = isset( $attributes['focalPoint'] ) ? round( $attributes['focalPoint']['x'] * 100 ) . '% ' . round( $attributes['focalPoint']['y'] * 100 ) . '%' : '50% 50%';
40
- $unique_id = 'wp-block-media-text__media-' . wp_unique_id();
41
58
 
42
59
  if ( $has_media_on_right ) {
43
60
  // Loop through all the figure tags and set a bookmark on the last figure tag.
@@ -46,59 +63,52 @@ function render_block_core_media_text( $attributes, $content ) {
46
63
  }
47
64
  if ( $media_tag_processor->has_bookmark( 'last_figure' ) ) {
48
65
  $media_tag_processor->seek( 'last_figure' );
49
- if ( $image_fill ) {
50
- $media_tag_processor->set_attribute( 'style', 'background-image:url(' . esc_url( $current_featured_image ) . ');background-position:' . $focal_point . ';' );
51
- } else {
52
- // Insert a unique ID to identify the figure tag.
53
- $media_tag_processor->set_attribute( 'id', $unique_id );
54
- }
66
+ // Insert a unique ID to identify the figure tag.
67
+ $media_tag_processor->set_attribute( 'id', $unique_id );
55
68
  }
56
69
  } else {
57
70
  if ( $media_tag_processor->next_tag( $wrapping_figure_query ) ) {
58
- if ( $image_fill ) {
59
- $media_tag_processor->set_attribute( 'style', 'background-image:url(' . esc_url( $current_featured_image ) . ');background-position:' . $focal_point . ';' );
60
- } else {
61
- // Insert a unique ID to identify the figure tag.
62
- $media_tag_processor->set_attribute( 'id', $unique_id );
63
- }
71
+ // Insert a unique ID to identify the figure tag.
72
+ $media_tag_processor->set_attribute( 'id', $unique_id );
64
73
  }
65
74
  }
66
75
 
67
76
  $content = $media_tag_processor->get_updated_html();
68
77
 
69
- // If the image is not set to fill, add the image tag inside the figure tag,
70
- // and update the image attributes in order to display the featured image.
71
- if ( ! $image_fill ) {
72
- $media_size_slug = isset( $attributes['mediaSizeSlug'] ) ? $attributes['mediaSizeSlug'] : 'full';
73
- $image_tag = '<img class="wp-block-media-text__featured_image">';
74
- $content = preg_replace(
75
- '/(<figure\s+id="' . preg_quote( $unique_id, '/' ) . '"\s+class="wp-block-media-text__media"\s*>)/',
76
- '$1' . $image_tag,
77
- $content
78
- );
78
+ // Add the image tag inside the figure tag, and update the image attributes
79
+ // in order to display the featured image.
80
+ $media_size_slug = isset( $attributes['mediaSizeSlug'] ) ? $attributes['mediaSizeSlug'] : 'full';
81
+ $image_tag = '<img class="wp-block-media-text__featured_image">';
82
+ $content = preg_replace(
83
+ '/(<figure\s+id="' . preg_quote( $unique_id, '/' ) . '"\s+class="wp-block-media-text__media"\s*>)/',
84
+ '$1' . $image_tag,
85
+ $content
86
+ );
79
87
 
80
- $image_tag_processor = new WP_HTML_Tag_Processor( $content );
88
+ $image_tag_processor = new WP_HTML_Tag_Processor( $content );
89
+ if ( $image_tag_processor->next_tag(
90
+ array(
91
+ 'tag_name' => 'figure',
92
+ 'id' => $unique_id,
93
+ )
94
+ ) ) {
95
+ // The ID is only used to ensure that the correct figure tag is selected,
96
+ // and can now be removed.
97
+ $image_tag_processor->remove_attribute( 'id' );
81
98
  if ( $image_tag_processor->next_tag(
82
99
  array(
83
- 'tag_name' => 'figure',
84
- 'id' => $unique_id,
100
+ 'tag_name' => 'img',
101
+ 'class_name' => 'wp-block-media-text__featured_image',
85
102
  )
86
103
  ) ) {
87
- // The ID is only used to ensure that the correct figure tag is selected,
88
- // and can now be removed.
89
- $image_tag_processor->remove_attribute( 'id' );
90
- if ( $image_tag_processor->next_tag(
91
- array(
92
- 'tag_name' => 'img',
93
- 'class_name' => 'wp-block-media-text__featured_image',
94
- )
95
- ) ) {
96
- $image_tag_processor->set_attribute( 'src', esc_url( $current_featured_image ) );
97
- $image_tag_processor->set_attribute( 'class', 'wp-image-' . get_post_thumbnail_id() . ' size-' . $media_size_slug );
98
- $image_tag_processor->set_attribute( 'alt', trim( strip_tags( get_post_meta( get_post_thumbnail_id(), '_wp_attachment_image_alt', true ) ) ) );
99
-
100
- $content = $image_tag_processor->get_updated_html();
104
+ $image_tag_processor->set_attribute( 'src', esc_url( $current_featured_image ) );
105
+ $image_tag_processor->set_attribute( 'class', 'wp-image-' . get_post_thumbnail_id() . ' size-' . $media_size_slug );
106
+ $image_tag_processor->set_attribute( 'alt', trim( strip_tags( get_post_meta( get_post_thumbnail_id(), '_wp_attachment_image_alt', true ) ) ) );
107
+ if ( $image_fill ) {
108
+ $image_tag_processor->set_attribute( 'style', 'object-position:' . $focal_point . ';' );
101
109
  }
110
+
111
+ $content = $image_tag_processor->get_updated_html();
102
112
  }
103
113
  }
104
114
 
@@ -22,25 +22,17 @@ import { isBlobURL } from '@wordpress/blob';
22
22
  import { store as noticesStore } from '@wordpress/notices';
23
23
  import { media as icon } from '@wordpress/icons';
24
24
 
25
+ /**
26
+ * Internal dependencies
27
+ */
28
+ import { imageFillStyles } from './image-fill';
29
+
25
30
  /**
26
31
  * Constants
27
32
  */
28
33
  const ALLOWED_MEDIA_TYPES = [ 'image', 'video' ];
29
34
  const noop = () => {};
30
35
 
31
- export function imageFillStyles( url, focalPoint ) {
32
- return url
33
- ? {
34
- backgroundImage: `url(${ url })`,
35
- backgroundPosition: focalPoint
36
- ? `${ Math.round( focalPoint.x * 100 ) }% ${ Math.round(
37
- focalPoint.y * 100
38
- ) }%`
39
- : `50% 50%`,
40
- }
41
- : {};
42
- }
43
-
44
36
  const ResizableBoxContainer = forwardRef(
45
37
  ( { isSelected, isStackedOnMobile, ...props }, ref ) => {
46
38
  const isMobile = useViewportMatch( 'small', '<' );
@@ -62,22 +54,18 @@ function ToolbarEditButton( {
62
54
  onSelectMedia,
63
55
  toggleUseFeaturedImage,
64
56
  useFeaturedImage,
65
- featuredImageURL,
66
57
  } ) {
67
58
  return (
68
59
  <BlockControls group="other">
69
60
  <MediaReplaceFlow
70
61
  mediaId={ mediaId }
71
- mediaUrl={
72
- useFeaturedImage && featuredImageURL
73
- ? featuredImageURL
74
- : mediaUrl
75
- }
62
+ mediaURL={ mediaUrl }
76
63
  allowedTypes={ ALLOWED_MEDIA_TYPES }
77
64
  accept="image/*,video/*"
78
65
  onSelect={ onSelectMedia }
79
66
  onToggleFeaturedImage={ toggleUseFeaturedImage }
80
67
  useFeaturedImage={ useFeaturedImage }
68
+ onReset={ () => onSelectMedia( undefined ) }
81
69
  />
82
70
  </BlockControls>
83
71
  );
@@ -133,6 +121,7 @@ function MediaContainer( props, ref ) {
133
121
  useFeaturedImage,
134
122
  featuredImageURL,
135
123
  featuredImageAlt,
124
+ refMedia,
136
125
  } = props;
137
126
 
138
127
  const isTemporaryMedia = ! mediaId && isBlobURL( mediaUrl );
@@ -155,7 +144,7 @@ function MediaContainer( props, ref ) {
155
144
  left: enableResize && mediaPosition === 'right',
156
145
  };
157
146
 
158
- const backgroundStyles =
147
+ const positionStyles =
159
148
  mediaType === 'image' && imageFill
160
149
  ? imageFillStyles( mediaUrl || featuredImageURL, focalPoint )
161
150
  : {};
@@ -163,11 +152,23 @@ function MediaContainer( props, ref ) {
163
152
  const mediaTypeRenderers = {
164
153
  image: () =>
165
154
  useFeaturedImage && featuredImageURL ? (
166
- <img src={ featuredImageURL } alt={ featuredImageAlt } />
155
+ <img
156
+ ref={ refMedia }
157
+ src={ featuredImageURL }
158
+ alt={ featuredImageAlt }
159
+ style={ positionStyles }
160
+ />
167
161
  ) : (
168
- mediaUrl && <img src={ mediaUrl } alt={ mediaAlt } />
162
+ mediaUrl && (
163
+ <img
164
+ ref={ refMedia }
165
+ src={ mediaUrl }
166
+ alt={ mediaAlt }
167
+ style={ positionStyles }
168
+ />
169
+ )
169
170
  ),
170
- video: () => <video controls src={ mediaUrl } />,
171
+ video: () => <video controls ref={ refMedia } src={ mediaUrl } />,
171
172
  };
172
173
 
173
174
  return (
@@ -178,7 +179,6 @@ function MediaContainer( props, ref ) {
178
179
  'editor-media-container__resizer',
179
180
  { 'is-transient': isTemporaryMedia }
180
181
  ) }
181
- style={ backgroundStyles }
182
182
  size={ { width: mediaWidth + '%' } }
183
183
  minWidth="10%"
184
184
  maxWidth="100%"
@@ -200,7 +200,6 @@ function MediaContainer( props, ref ) {
200
200
  }
201
201
  mediaId={ mediaId }
202
202
  toggleUseFeaturedImage={ toggleUseFeaturedImage }
203
- useFeaturedImage={ useFeaturedImage }
204
203
  />
205
204
  { ( mediaTypeRenderers[ mediaType ] || noop )() }
206
205
  { isTemporaryMedia && <Spinner /> }
@@ -208,6 +207,7 @@ function MediaContainer( props, ref ) {
208
207
  { ! featuredImageURL && useFeaturedImage && (
209
208
  <Placeholder
210
209
  className="wp-block-media-text--placeholder-image"
210
+ style={ positionStyles }
211
211
  withIllustration
212
212
  />
213
213
  ) }
@@ -44,8 +44,6 @@ const ICON_TYPE = {
44
44
  RETRY: 'retry',
45
45
  };
46
46
 
47
- export { imageFillStyles } from './media-container.js';
48
-
49
47
  class MediaContainer extends Component {
50
48
  constructor() {
51
49
  super( ...arguments );
@@ -11,7 +11,7 @@ import { useInnerBlocksProps, useBlockProps } from '@wordpress/block-editor';
11
11
  /**
12
12
  * Internal dependencies
13
13
  */
14
- import { imageFillStyles } from './media-container';
14
+ import { imageFillStyles } from './image-fill';
15
15
  import { DEFAULT_MEDIA_SIZE_SLUG } from './constants';
16
16
 
17
17
  const DEFAULT_MEDIA_WIDTH = 50;
@@ -42,11 +42,16 @@ export default function save( { attributes } ) {
42
42
  [ `size-${ mediaSizeSlug }` ]: mediaId && mediaType === 'image',
43
43
  } );
44
44
 
45
+ const positionStyles = imageFill
46
+ ? imageFillStyles( mediaUrl, focalPoint )
47
+ : {};
48
+
45
49
  let image = mediaUrl ? (
46
50
  <img
47
51
  src={ mediaUrl }
48
52
  alt={ mediaAlt }
49
53
  className={ imageClasses || null }
54
+ style={ positionStyles }
50
55
  />
51
56
  ) : null;
52
57
 
@@ -71,11 +76,8 @@ export default function save( { attributes } ) {
71
76
  'has-media-on-the-right': 'right' === mediaPosition,
72
77
  'is-stacked-on-mobile': isStackedOnMobile,
73
78
  [ `is-vertically-aligned-${ verticalAlignment }` ]: verticalAlignment,
74
- 'is-image-fill': imageFill,
79
+ 'is-image-fill-element': imageFill,
75
80
  } );
76
- const backgroundStyles = imageFill
77
- ? imageFillStyles( mediaUrl, focalPoint )
78
- : {};
79
81
 
80
82
  let gridTemplateColumns;
81
83
  if ( mediaWidth !== DEFAULT_MEDIA_WIDTH ) {
@@ -96,10 +98,7 @@ export default function save( { attributes } ) {
96
98
  className: 'wp-block-media-text__content',
97
99
  } ) }
98
100
  />
99
- <figure
100
- className="wp-block-media-text__media"
101
- style={ backgroundStyles }
102
- >
101
+ <figure className="wp-block-media-text__media">
103
102
  { ( mediaTypeRenders[ mediaType ] || noop )() }
104
103
  </figure>
105
104
  </div>
@@ -107,10 +106,7 @@ export default function save( { attributes } ) {
107
106
  }
108
107
  return (
109
108
  <div { ...useBlockProps.save( { className, style } ) }>
110
- <figure
111
- className="wp-block-media-text__media"
112
- style={ backgroundStyles }
113
- >
109
+ <figure className="wp-block-media-text__media">
114
110
  { ( mediaTypeRenders[ mediaType ] || noop )() }
115
111
  </figure>
116
112
  <div
@@ -80,6 +80,7 @@
80
80
  vertical-align: middle;
81
81
  }
82
82
 
83
+ /* `is-image-fill` is deprecated and the styles are kept for backwards compatibility. */
83
84
  .wp-block-media-text.is-image-fill > .wp-block-media-text__media {
84
85
  height: 100%;
85
86
  min-height: 250px;
@@ -102,6 +103,26 @@
102
103
  clip: rect(0, 0, 0, 0);
103
104
  border: 0;
104
105
  }
106
+
107
+ /* Image fill for versions 8 and onwards */
108
+ .wp-block-media-text.is-image-fill-element > .wp-block-media-text__media {
109
+ position: relative;
110
+ height: 100%;
111
+ min-height: 250px;
112
+ }
113
+
114
+ .wp-block-media-text.is-image-fill-element > .wp-block-media-text__media > a {
115
+ display: block;
116
+ height: 100%;
117
+ }
118
+
119
+ .wp-block-media-text.is-image-fill-element > .wp-block-media-text__media img {
120
+ position: absolute;
121
+ width: 100%;
122
+ height: 100%;
123
+ object-fit: cover;
124
+ }
125
+
105
126
  /*
106
127
  * Here we here not able to use a mobile first CSS approach.
107
128
  * Custom widths are set using inline styles, and on mobile,
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Internal dependencies
3
+ */
4
+ import { imageFillStyles } from '../image-fill';
5
+
6
+ describe( 'imageFillStyles()', () => {
7
+ it( 'should return centered object position', () => {
8
+ const { objectPosition } = imageFillStyles( 'image.jpg' );
9
+ expect( objectPosition ).toBe( '50% 50%' );
10
+ } );
11
+
12
+ it( 'should return custom object position', () => {
13
+ const { objectPosition } = imageFillStyles( 'image.jpg', {
14
+ x: 0.56,
15
+ y: 0.57,
16
+ } );
17
+ expect( objectPosition ).toBe( '56% 57%' );
18
+ } );
19
+ } );
@@ -49,7 +49,13 @@ export default function MissingEdit( { attributes, clientId } ) {
49
49
  let messageHTML;
50
50
 
51
51
  const convertToHtmlButton = (
52
- <Button key="convert" onClick={ convertToHTML } variant="primary">
52
+ <Button
53
+ // TODO: Switch to `true` (40px size) if possible
54
+ __next40pxDefaultSize={ false }
55
+ key="convert"
56
+ onClick={ convertToHTML }
57
+ variant="primary"
58
+ >
53
59
  { __( 'Keep as HTML' ) }
54
60
  </Button>
55
61
  );
@@ -69,7 +75,7 @@ export default function MissingEdit( { attributes, clientId } ) {
69
75
  messageHTML = sprintf(
70
76
  /* translators: %s: block name */
71
77
  __(
72
- 'Your site doesn’t include support for the "%s" block. You can leave this block intact, convert its content to a Custom HTML block, or remove it entirely.'
78
+ 'Your site doesn’t include support for the "%s" block. You can leave it as-is, convert it to custom HTML, or remove it.'
73
79
  ),
74
80
  originalName
75
81
  );
@@ -78,7 +84,7 @@ export default function MissingEdit( { attributes, clientId } ) {
78
84
  messageHTML = sprintf(
79
85
  /* translators: %s: block name */
80
86
  __(
81
- 'Your site doesn’t include support for the "%s" block. You can leave this block intact or remove it entirely.'
87
+ 'Your site doesn’t include support for the "%s" block. You can leave it as-is or remove it.'
82
88
  ),
83
89
  originalName
84
90
  );
@@ -14,7 +14,14 @@ function DeletedNavigationWarning( { onCreateNew } ) {
14
14
  'Navigation Menu has been deleted or is unavailable. <button>Create a new Menu?</button>'
15
15
  ),
16
16
  {
17
- button: <Button onClick={ onCreateNew } variant="link" />,
17
+ button: (
18
+ <Button
19
+ // TODO: Switch to `true` (40px size) if possible
20
+ __next40pxDefaultSize={ false }
21
+ onClick={ onCreateNew }
22
+ variant="link"
23
+ />
24
+ ),
18
25
  }
19
26
  ) }
20
27
  </Warning>
@@ -591,6 +591,8 @@ function Navigation( {
591
591
  { isResponsive && (
592
592
  <>
593
593
  <Button
594
+ // TODO: Switch to `true` (40px size) if possible
595
+ __next40pxDefaultSize={ false }
594
596
  className={ overlayMenuPreviewClasses }
595
597
  onClick={ () => {
596
598
  setOverlayMenuPreview(
@@ -19,6 +19,8 @@ export default function NavigationMenuDeleteControl( { onDelete } ) {
19
19
  return (
20
20
  <>
21
21
  <Button
22
+ // TODO: Switch to `true` (40px size) if possible
23
+ __next40pxDefaultSize={ false }
22
24
  className="wp-block-navigation-delete-menu-button"
23
25
  variant="secondary"
24
26
  isDestructive
@@ -76,6 +76,8 @@ export default function NavigationPlaceholder( {
76
76
 
77
77
  { canUserCreateNavigationMenus && (
78
78
  <Button
79
+ // TODO: Switch to `true` (40px size) if possible
80
+ __next40pxDefaultSize={ false }
79
81
  variant="tertiary"
80
82
  onClick={ onCreateEmpty }
81
83
  >
@@ -79,6 +79,8 @@ export default function ResponsiveWrapper( {
79
79
  <>
80
80
  { ! isOpen && (
81
81
  <Button
82
+ // TODO: Switch to `true` (40px size) if possible
83
+ __next40pxDefaultSize={ false }
82
84
  aria-haspopup="true"
83
85
  aria-label={ hasIcon && __( 'Open menu' ) }
84
86
  className={ openButtonClasses }
@@ -100,6 +102,8 @@ export default function ResponsiveWrapper( {
100
102
  >
101
103
  <div { ...dialogProps }>
102
104
  <Button
105
+ // TODO: Switch to `true` (40px size) if possible
106
+ __next40pxDefaultSize={ false }
103
107
  className="wp-block-navigation__responsive-container-close"
104
108
  aria-label={ hasIcon && __( 'Close menu' ) }
105
109
  onClick={ () => onToggle( false ) }
@@ -20,13 +20,13 @@ export default function UnsavedInnerBlocks( {
20
20
  createNavigationMenu,
21
21
  hasSelection,
22
22
  } ) {
23
- const originalBlocks = useRef();
23
+ const originalBlocksRef = useRef();
24
24
 
25
25
  useEffect( () => {
26
26
  // Initially store the uncontrolled inner blocks for
27
27
  // dirty state comparison.
28
- if ( ! originalBlocks?.current ) {
29
- originalBlocks.current = blocks;
28
+ if ( ! originalBlocksRef?.current ) {
29
+ originalBlocksRef.current = blocks;
30
30
  }
31
31
  }, [ blocks ] );
32
32
 
@@ -38,7 +38,7 @@ export default function UnsavedInnerBlocks( {
38
38
  // entity records. As a result we need to perform a deep equality check skipping
39
39
  // the page list's inner blocks.
40
40
  const innerBlocksAreDirty = areBlocksDirty(
41
- originalBlocks?.current,
41
+ originalBlocksRef?.current,
42
42
  blocks
43
43
  );
44
44
 
@@ -5,6 +5,10 @@
5
5
  // Undo default editor styles.
6
6
  // These need extra specificity.
7
7
  .editor-styles-wrapper .wp-block-navigation {
8
+ // Extra specificity is applied to do two things in classic themes:
9
+ // 1. Override the auto margin from alignment styles. This is needed as the `ul` element
10
+ // has a `wp-block` class applied to it, even though it's not a block.
11
+ // 2. Override list indentation that targets `ul,ol` elements.
8
12
  ul {
9
13
  margin-top: 0;
10
14
  margin-bottom: 0;
@@ -100,7 +104,6 @@
100
104
  background: $gray-900;
101
105
  padding: 0;
102
106
  width: $button-size-small;
103
- border-radius: $radius-block-ui;
104
107
  margin-right: 0;
105
108
  margin-left: auto;
106
109
  }
@@ -322,7 +325,7 @@ $color-control-label-height: 20px;
322
325
  }
323
326
 
324
327
  .wp-block-navigation-placeholder__controls {
325
- border-radius: $radius-block-ui;
328
+ border-radius: $radius-small;
326
329
  background-color: $white;
327
330
  box-shadow: inset 0 0 0 $border-width $gray-900;
328
331
  display: none;
@@ -478,7 +481,7 @@ $color-control-label-height: 20px;
478
481
  }
479
482
  }
480
483
 
481
- // The iframe makes these rules a lot simpler.
484
+ // `body.editor-styles-wrapper` ensures this only applies to the iframed editor.
482
485
  body.editor-styles-wrapper .wp-block-navigation__responsive-container.is-menu-open {
483
486
  top: 0;
484
487
  right: 0;
@@ -8,7 +8,7 @@ import {
8
8
  VisuallyHidden,
9
9
  __experimentalVStack as VStack,
10
10
  } from '@wordpress/components';
11
- import { __, sprintf } from '@wordpress/i18n';
11
+ import { __, sprintf, isRTL } from '@wordpress/i18n';
12
12
  import {
13
13
  __experimentalLinkControl as LinkControl,
14
14
  store as blockEditorStore,
@@ -28,7 +28,7 @@ import {
28
28
  } from '@wordpress/core-data';
29
29
  import { decodeEntities } from '@wordpress/html-entities';
30
30
  import { useSelect, useDispatch } from '@wordpress/data';
31
- import { chevronLeftSmall, plus } from '@wordpress/icons';
31
+ import { chevronLeftSmall, chevronRightSmall, plus } from '@wordpress/icons';
32
32
  import { useInstanceId, useFocusOnMount } from '@wordpress/compose';
33
33
 
34
34
  /**
@@ -123,7 +123,7 @@ function LinkUIBlockInserter( { clientId, onBack, onSelectBlock } ) {
123
123
 
124
124
  <Button
125
125
  className="link-ui-block-inserter__back"
126
- icon={ chevronLeftSmall }
126
+ icon={ isRTL() ? chevronRightSmall : chevronLeftSmall }
127
127
  onClick={ ( e ) => {
128
128
  e.preventDefault();
129
129
  onBack();
@@ -310,6 +310,8 @@ const LinkUITools = ( { setAddingBlock, focusAddBlockButton } ) => {
310
310
  return (
311
311
  <VStack className="link-ui-tools">
312
312
  <Button
313
+ // TODO: Switch to `true` (40px size) if possible
314
+ __next40pxDefaultSize={ false }
313
315
  ref={ addBlockButtonRef }
314
316
  icon={ plus }
315
317
  onClick={ ( e ) => {
@@ -31,10 +31,17 @@ export function ConvertToLinksModal( { onClick, onClose, disabled } ) {
31
31
  { convertDescription }
32
32
  </p>
33
33
  <div className="wp-block-page-list-modal-buttons">
34
- <Button variant="tertiary" onClick={ onClose }>
34
+ <Button
35
+ // TODO: Switch to `true` (40px size) if possible
36
+ __next40pxDefaultSize={ false }
37
+ variant="tertiary"
38
+ onClick={ onClose }
39
+ >
35
40
  { __( 'Cancel' ) }
36
41
  </Button>
37
42
  <Button
43
+ // TODO: Switch to `true` (40px size) if possible
44
+ __next40pxDefaultSize={ false }
38
45
  variant="primary"
39
46
  accessibleWhenDisabled
40
47
  disabled={ disabled }
@@ -225,7 +225,11 @@ export default function PageListEdit( {
225
225
  page.title?.rendered?.trim() !== ''
226
226
  ? page.title?.rendered
227
227
  : __( '(no title)' ),
228
- title: page.title?.rendered,
228
+ title:
229
+ // translators: displayed when a page has an empty title.
230
+ page.title?.rendered?.trim() !== ''
231
+ ? page.title?.rendered
232
+ : __( '(no title)' ),
229
233
  link: page.url,
230
234
  hasChildren,
231
235
  };
@@ -338,6 +342,8 @@ export default function PageListEdit( {
338
342
  <PanelBody title={ __( 'Edit this menu' ) }>
339
343
  <p>{ convertDescription }</p>
340
344
  <Button
345
+ // TODO: Switch to `true` (40px size) if possible
346
+ __next40pxDefaultSize={ false }
341
347
  variant="primary"
342
348
  accessibleWhenDisabled
343
349
  disabled={ ! hasResolvedPages }
@@ -192,7 +192,9 @@ function block_core_page_list_render_nested_page_list( $open_submenus_on_click,
192
192
  $css_class .= ' menu-item-home';
193
193
  }
194
194
 
195
- $title = wp_kses_post( $page['title'] );
195
+ $title = wp_kses_post( $page['title'] );
196
+ $title = $title ? $title : __( '(no title)' );
197
+
196
198
  $aria_label = sprintf(
197
199
  /* translators: Accessibility text. %s: Parent page title. */
198
200
  __( '%s submenu' ),
@@ -84,6 +84,8 @@ const CommentsForm = ( { postId, postType } ) => {
84
84
  if ( 'closed' === commentStatus ) {
85
85
  const actions = [
86
86
  <Button
87
+ // TODO: Switch to `true` (40px size) if possible
88
+ __next40pxDefaultSize={ false }
87
89
  key="enableComments"
88
90
  onClick={ () => setCommentStatus( 'open' ) }
89
91
  variant="primary"