@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
@@ -75,10 +75,10 @@ function ClassicEdit( {
75
75
  onReplace,
76
76
  } ) {
77
77
  const { getMultiSelectedBlockClientIds } = useSelect( blockEditorStore );
78
- const didMount = useRef( false );
78
+ const didMountRef = useRef( false );
79
79
 
80
80
  useEffect( () => {
81
- if ( ! didMount.current ) {
81
+ if ( ! didMountRef.current ) {
82
82
  return;
83
83
  }
84
84
 
@@ -96,7 +96,7 @@ function ClassicEdit( {
96
96
  useEffect( () => {
97
97
  const { baseURL, suffix } = window.wpEditorL10n.tinymce;
98
98
 
99
- didMount.current = true;
99
+ didMountRef.current = true;
100
100
 
101
101
  window.tinymce.EditorManager.overrideDefaults( {
102
102
  base_url: baseURL,
@@ -230,7 +230,7 @@ function ClassicEdit( {
230
230
  onReadyStateChange
231
231
  );
232
232
  wp.oldEditor.remove( `editor-${ clientId }` );
233
- didMount.current = false;
233
+ didMountRef.current = false;
234
234
  };
235
235
  }, [] );
236
236
 
@@ -299,7 +299,7 @@ div[data-type="core/freeform"] {
299
299
  top: 0;
300
300
  border: $border-width solid $gray-300;
301
301
  border-bottom: none;
302
- border-radius: $radius-block-ui;
302
+ border-radius: $radius-small;
303
303
  margin-bottom: $grid-unit-10;
304
304
 
305
305
  // On mobile, toolbars go edge to edge.
@@ -25,6 +25,8 @@ function ModalAuxiliaryActions( { onClick, isModalFullScreen } ) {
25
25
 
26
26
  return (
27
27
  <Button
28
+ // TODO: Switch to `true` (40px size) if possible
29
+ __next40pxDefaultSize={ false }
28
30
  onClick={ onClick }
29
31
  icon={ fullscreen }
30
32
  isPressed={ isModalFullScreen }
@@ -120,12 +122,19 @@ export default function ModalEdit( props ) {
120
122
  expanded={ false }
121
123
  >
122
124
  <FlexItem>
123
- <Button variant="tertiary" onClick={ onClose }>
125
+ <Button
126
+ // TODO: Switch to `true` (40px size) if possible
127
+ __next40pxDefaultSize={ false }
128
+ variant="tertiary"
129
+ onClick={ onClose }
130
+ >
124
131
  { __( 'Cancel' ) }
125
132
  </Button>
126
133
  </FlexItem>
127
134
  <FlexItem>
128
135
  <Button
136
+ // TODO: Switch to `true` (40px size) if possible
137
+ __next40pxDefaultSize={ false }
129
138
  variant="primary"
130
139
  onClick={ () => {
131
140
  setAttributes( {
@@ -139,7 +139,7 @@
139
139
  z-index: z-index(".block-library-gallery-item__inline-menu");
140
140
  transition: box-shadow 0.2s ease-out;
141
141
  @include reduce-motion("transition");
142
- border-radius: $radius-block-ui;
142
+ border-radius: $radius-small;
143
143
  background: $white;
144
144
  border: $border-width solid $gray-900;
145
145
 
@@ -43,7 +43,6 @@
43
43
  pointer-events: none;
44
44
  min-height: $grid-unit-60 - $border-width - $border-width;
45
45
  border: $border-width dashed currentColor;
46
- border-radius: $radius-block-ui;
47
46
  }
48
47
 
49
48
  // Let the parent be selectable in the placeholder area.
@@ -19,13 +19,10 @@ import { useEffect } from '@wordpress/element';
19
19
  const preventDefault = ( event ) => event.preventDefault();
20
20
 
21
21
  export default function HomeEdit( { attributes, setAttributes, context } ) {
22
- const { homeUrl } = useSelect( ( select ) => {
23
- const {
24
- getUnstableBase, // Site index.
25
- } = select( coreStore );
26
- return {
27
- homeUrl: getUnstableBase()?.home,
28
- };
22
+ const homeUrl = useSelect( ( select ) => {
23
+ // Site index.
24
+ return select( coreStore ).getEntityRecord( 'root', '__unstableBase' )
25
+ ?.home;
29
26
  }, [] );
30
27
  const { __unstableMarkNextChangeAsNotPersistent } =
31
28
  useDispatch( blockEditorStore );
package/src/image/edit.js CHANGED
@@ -23,6 +23,7 @@ import { useEffect, useRef, useState } from '@wordpress/element';
23
23
  import { __, sprintf } from '@wordpress/i18n';
24
24
  import { image as icon, plugins as pluginsIcon } from '@wordpress/icons';
25
25
  import { store as noticesStore } from '@wordpress/notices';
26
+ import { useResizeObserver } from '@wordpress/compose';
26
27
 
27
28
  /**
28
29
  * Internal dependencies
@@ -109,6 +110,9 @@ export function ImageEdit( {
109
110
  } = attributes;
110
111
  const [ temporaryURL, setTemporaryURL ] = useState( attributes.blob );
111
112
 
113
+ const [ contentResizeListener, { width: containerWidth } ] =
114
+ useResizeObserver();
115
+
112
116
  const altRef = useRef();
113
117
  useEffect( () => {
114
118
  altRef.current = alt;
@@ -322,7 +326,7 @@ export function ImageEdit( {
322
326
  : __( 'Connected to dynamic data' ),
323
327
  };
324
328
  },
325
- [ isSingleSelected, metadata?.bindings?.url ]
329
+ [ context, isSingleSelected, metadata?.bindings?.url ]
326
330
  );
327
331
  const placeholder = ( content ) => {
328
332
  return (
@@ -364,35 +368,43 @@ export function ImageEdit( {
364
368
  };
365
369
 
366
370
  return (
367
- <figure { ...blockProps }>
368
- <Image
369
- temporaryURL={ temporaryURL }
370
- attributes={ attributes }
371
- setAttributes={ setAttributes }
372
- isSingleSelected={ isSingleSelected }
373
- insertBlocksAfter={ insertBlocksAfter }
374
- onReplace={ onReplace }
375
- onSelectImage={ onSelectImage }
376
- onSelectURL={ onSelectURL }
377
- onUploadError={ onUploadError }
378
- context={ context }
379
- clientId={ clientId }
380
- blockEditingMode={ blockEditingMode }
381
- parentLayoutType={ parentLayout?.type }
382
- />
383
- <MediaPlaceholder
384
- icon={ <BlockIcon icon={ icon } /> }
385
- onSelect={ onSelectImage }
386
- onSelectURL={ onSelectURL }
387
- onError={ onUploadError }
388
- placeholder={ placeholder }
389
- accept="image/*"
390
- allowedTypes={ ALLOWED_MEDIA_TYPES }
391
- value={ { id, src } }
392
- mediaPreview={ mediaPreview }
393
- disableMediaButtons={ temporaryURL || url }
394
- />
395
- </figure>
371
+ <>
372
+ <figure { ...blockProps }>
373
+ <Image
374
+ temporaryURL={ temporaryURL }
375
+ attributes={ attributes }
376
+ setAttributes={ setAttributes }
377
+ isSingleSelected={ isSingleSelected }
378
+ insertBlocksAfter={ insertBlocksAfter }
379
+ onReplace={ onReplace }
380
+ onSelectImage={ onSelectImage }
381
+ onSelectURL={ onSelectURL }
382
+ onUploadError={ onUploadError }
383
+ context={ context }
384
+ clientId={ clientId }
385
+ blockEditingMode={ blockEditingMode }
386
+ parentLayoutType={ parentLayout?.type }
387
+ containerWidth={ containerWidth }
388
+ />
389
+ <MediaPlaceholder
390
+ icon={ <BlockIcon icon={ icon } /> }
391
+ onSelect={ onSelectImage }
392
+ onSelectURL={ onSelectURL }
393
+ onError={ onUploadError }
394
+ placeholder={ placeholder }
395
+ accept="image/*"
396
+ allowedTypes={ ALLOWED_MEDIA_TYPES }
397
+ value={ { id, src } }
398
+ mediaPreview={ mediaPreview }
399
+ disableMediaButtons={ temporaryURL || url }
400
+ />
401
+ </figure>
402
+ {
403
+ // The listener cannot be placed as the first element as it will break the in-between inserter.
404
+ // See https://github.com/WordPress/gutenberg/blob/71134165868298fc15e22896d0c28b41b3755ff7/packages/block-editor/src/components/block-list/use-in-between-inserter.js#L120
405
+ contentResizeListener
406
+ }
407
+ </>
396
408
  );
397
409
  }
398
410
 
@@ -13,9 +13,6 @@
13
13
  // Disable any duotone filter applied in the selected state.
14
14
  filter: none !important;
15
15
 
16
- // @todo this should eventually be overridden by a custom border-radius set in the inspector.
17
- border-radius: $radius-block-ui;
18
-
19
16
  > svg {
20
17
  opacity: 0;
21
18
  }
@@ -3,7 +3,6 @@
3
3
  */
4
4
  import { isBlobURL } from '@wordpress/blob';
5
5
  import {
6
- MenuItem,
7
6
  ExternalLink,
8
7
  ResizableBox,
9
8
  Spinner,
@@ -109,6 +108,7 @@ export default function Image( {
109
108
  clientId,
110
109
  blockEditingMode,
111
110
  parentLayoutType,
111
+ containerWidth,
112
112
  } ) {
113
113
  const {
114
114
  url = '',
@@ -357,7 +357,11 @@ export default function Image( {
357
357
  }, [ isSingleSelected ] );
358
358
 
359
359
  const canEditImage = id && naturalWidth && naturalHeight && imageEditing;
360
- const allowCrop = isSingleSelected && canEditImage && ! isEditingImage;
360
+ const allowCrop =
361
+ isSingleSelected &&
362
+ canEditImage &&
363
+ ! isEditingImage &&
364
+ ! isContentOnlyMode;
361
365
 
362
366
  function switchToCover() {
363
367
  replaceBlocks(
@@ -598,11 +602,8 @@ export default function Image( {
598
602
  onSelect={ onSelectImage }
599
603
  onSelectURL={ onSelectURL }
600
604
  onError={ onUploadError }
601
- >
602
- <MenuItem onClick={ () => onSelectImage( undefined ) }>
603
- { __( 'Reset' ) }
604
- </MenuItem>
605
- </MediaReplaceFlow>
605
+ onReset={ () => onSelectImage( undefined ) }
606
+ />
606
607
  </BlockControls>
607
608
  ) }
608
609
  { isSingleSelected && externalBlob && (
@@ -636,7 +637,7 @@ export default function Image( {
636
637
  } }
637
638
  >
638
639
  { _x(
639
- 'Alt',
640
+ 'Alternative text',
640
641
  'Alternative text for an image. Block toolbar label, a low character count is preferred.'
641
642
  ) }
642
643
  </ToolbarButton>
@@ -676,51 +677,56 @@ export default function Image( {
676
677
  />
677
678
  ) }
678
679
  />
679
- <Dropdown
680
- popoverProps={ { position: 'bottom right' } }
681
- renderToggle={ ( { isOpen, onToggle } ) => (
682
- <ToolbarButton
683
- onClick={ onToggle }
684
- aria-haspopup="true"
685
- aria-expanded={ isOpen }
686
- onKeyDown={ ( event ) => {
687
- if ( ! isOpen && event.keyCode === DOWN ) {
688
- event.preventDefault();
689
- onToggle();
690
- }
691
- } }
692
- >
693
- { __( 'Title' ) }
694
- </ToolbarButton>
695
- ) }
696
- renderContent={ () => (
697
- <TextControl
698
- __next40pxDefaultSize
699
- className="wp-block-image__toolbar_content_textarea"
700
- __nextHasNoMarginBottom
701
- label={ __( 'Title attribute' ) }
702
- value={ title || '' }
703
- onChange={ onSetTitle }
704
- disabled={ lockTitleControls }
705
- help={
706
- lockTitleControls ? (
707
- <>{ lockTitleControlsMessage }</>
708
- ) : (
709
- <>
710
- { __(
711
- 'Describe the role of this image on the page.'
712
- ) }
713
- <ExternalLink href="https://www.w3.org/TR/html52/dom.html#the-title-attribute">
680
+ { title && (
681
+ <Dropdown
682
+ popoverProps={ { position: 'bottom right' } }
683
+ renderToggle={ ( { isOpen, onToggle } ) => (
684
+ <ToolbarButton
685
+ onClick={ onToggle }
686
+ aria-haspopup="true"
687
+ aria-expanded={ isOpen }
688
+ onKeyDown={ ( event ) => {
689
+ if (
690
+ ! isOpen &&
691
+ event.keyCode === DOWN
692
+ ) {
693
+ event.preventDefault();
694
+ onToggle();
695
+ }
696
+ } }
697
+ >
698
+ { __( 'Title' ) }
699
+ </ToolbarButton>
700
+ ) }
701
+ renderContent={ () => (
702
+ <TextControl
703
+ __next40pxDefaultSize
704
+ className="wp-block-image__toolbar_content_textarea"
705
+ __nextHasNoMarginBottom
706
+ label={ __( 'Title attribute' ) }
707
+ value={ title || '' }
708
+ onChange={ onSetTitle }
709
+ disabled={ lockTitleControls }
710
+ help={
711
+ lockTitleControls ? (
712
+ <>{ lockTitleControlsMessage }</>
713
+ ) : (
714
+ <>
714
715
  { __(
715
- '(Note: many devices and browsers do not display this text.)'
716
+ 'Describe the role of this image on the page.'
716
717
  ) }
717
- </ExternalLink>
718
- </>
719
- )
720
- }
721
- />
722
- ) }
723
- />
718
+ <ExternalLink href="https://www.w3.org/TR/html52/dom.html#the-title-attribute">
719
+ { __(
720
+ '(Note: many devices and browsers do not display this text.)'
721
+ ) }
722
+ </ExternalLink>
723
+ </>
724
+ )
725
+ }
726
+ />
727
+ ) }
728
+ />
729
+ ) }
724
730
  </BlockControls>
725
731
  ) }
726
732
  <InspectorControls>
@@ -928,6 +934,7 @@ export default function Image( {
928
934
  // @todo It would be good to revisit this once a content-width variable
929
935
  // becomes available.
930
936
  const maxWidthBuffer = maxWidth * 2.5;
937
+ const maxContentWidth = containerWidth || maxWidthBuffer;
931
938
 
932
939
  let showRightHandle = false;
933
940
  let showLeftHandle = false;
@@ -973,9 +980,9 @@ export default function Image( {
973
980
  } }
974
981
  showHandle={ isSingleSelected }
975
982
  minWidth={ minWidth }
976
- maxWidth={ maxWidthBuffer }
983
+ maxWidth={ maxContentWidth }
977
984
  minHeight={ minHeight }
978
- maxHeight={ maxWidthBuffer / ratio }
985
+ maxHeight={ maxContentWidth / ratio }
979
986
  lockAspectRatio={ ratio }
980
987
  enable={ {
981
988
  top: false,
@@ -986,6 +993,21 @@ export default function Image( {
986
993
  onResizeStart={ onResizeStart }
987
994
  onResizeStop={ ( event, direction, elt ) => {
988
995
  onResizeStop();
996
+
997
+ // Clear hardcoded width if the resized width is close to the max-content width.
998
+ if (
999
+ // Only do this if the image is bigger than the container to prevent it from being squished.
1000
+ // TODO: Remove this check if the image support setting 100% width.
1001
+ naturalWidth >= maxContentWidth &&
1002
+ Math.abs( elt.offsetWidth - maxContentWidth ) < 10
1003
+ ) {
1004
+ setAttributes( {
1005
+ width: undefined,
1006
+ height: undefined,
1007
+ } );
1008
+ return;
1009
+ }
1010
+
989
1011
  // Since the aspect ratio is locked when resizing, we can
990
1012
  // use the width of the resized element to calculate the
991
1013
  // height in CSS to prevent stretching when the max-width
@@ -30,7 +30,7 @@ const v1ToV5ImageFillStyles = ( url, focalPoint ) => {
30
30
  : {};
31
31
  };
32
32
 
33
- const v6ImageFillStyles = ( url, focalPoint ) => {
33
+ const v6ToV7ImageFillStyles = ( url, focalPoint ) => {
34
34
  return url
35
35
  ? {
36
36
  backgroundImage: `url(${ url })`,
@@ -198,6 +198,20 @@ const v6Attributes = {
198
198
  },
199
199
  };
200
200
 
201
+ const v7Attributes = {
202
+ ...v6Attributes,
203
+ align: {
204
+ type: 'string',
205
+ // v7 changed the default for the `align` attribute.
206
+ default: 'none',
207
+ },
208
+ // New attribute.
209
+ useFeaturedImage: {
210
+ type: 'boolean',
211
+ default: false,
212
+ },
213
+ };
214
+
201
215
  const v4ToV5Supports = {
202
216
  anchor: true,
203
217
  align: [ 'wide', 'full' ],
@@ -237,6 +251,148 @@ const v6Supports = {
237
251
  },
238
252
  };
239
253
 
254
+ const v7Supports = {
255
+ ...v6Supports,
256
+ __experimentalBorder: {
257
+ color: true,
258
+ radius: true,
259
+ style: true,
260
+ width: true,
261
+ __experimentalDefaultControls: {
262
+ color: true,
263
+ radius: true,
264
+ style: true,
265
+ width: true,
266
+ },
267
+ },
268
+ color: {
269
+ gradients: true,
270
+ heading: true,
271
+ link: true,
272
+ __experimentalDefaultControls: {
273
+ background: true,
274
+ text: true,
275
+ },
276
+ },
277
+ interactivity: {
278
+ clientNavigation: true,
279
+ },
280
+ };
281
+
282
+ // Version with 'none' as the default alignment.
283
+ // See: https://github.com/WordPress/gutenberg/pull/64981
284
+ const v7 = {
285
+ attributes: v7Attributes,
286
+ supports: v7Supports,
287
+ usesContext: [ 'postId', 'postType' ],
288
+ save( { attributes } ) {
289
+ const {
290
+ isStackedOnMobile,
291
+ mediaAlt,
292
+ mediaPosition,
293
+ mediaType,
294
+ mediaUrl,
295
+ mediaWidth,
296
+ mediaId,
297
+ verticalAlignment,
298
+ imageFill,
299
+ focalPoint,
300
+ linkClass,
301
+ href,
302
+ linkTarget,
303
+ rel,
304
+ } = attributes;
305
+ const mediaSizeSlug =
306
+ attributes.mediaSizeSlug || DEFAULT_MEDIA_SIZE_SLUG;
307
+ const newRel = ! rel ? undefined : rel;
308
+
309
+ const imageClasses = clsx( {
310
+ [ `wp-image-${ mediaId }` ]: mediaId && mediaType === 'image',
311
+ [ `size-${ mediaSizeSlug }` ]: mediaId && mediaType === 'image',
312
+ } );
313
+
314
+ let image = mediaUrl ? (
315
+ <img
316
+ src={ mediaUrl }
317
+ alt={ mediaAlt }
318
+ className={ imageClasses || null }
319
+ />
320
+ ) : null;
321
+
322
+ if ( href ) {
323
+ image = (
324
+ <a
325
+ className={ linkClass }
326
+ href={ href }
327
+ target={ linkTarget }
328
+ rel={ newRel }
329
+ >
330
+ { image }
331
+ </a>
332
+ );
333
+ }
334
+
335
+ const mediaTypeRenders = {
336
+ image: () => image,
337
+ video: () => <video controls src={ mediaUrl } />,
338
+ };
339
+ const className = clsx( {
340
+ 'has-media-on-the-right': 'right' === mediaPosition,
341
+ 'is-stacked-on-mobile': isStackedOnMobile,
342
+ [ `is-vertically-aligned-${ verticalAlignment }` ]:
343
+ verticalAlignment,
344
+ 'is-image-fill': imageFill,
345
+ } );
346
+ const backgroundStyles = imageFill
347
+ ? v6ToV7ImageFillStyles( mediaUrl, focalPoint )
348
+ : {};
349
+
350
+ let gridTemplateColumns;
351
+ if ( mediaWidth !== DEFAULT_MEDIA_WIDTH ) {
352
+ gridTemplateColumns =
353
+ 'right' === mediaPosition
354
+ ? `auto ${ mediaWidth }%`
355
+ : `${ mediaWidth }% auto`;
356
+ }
357
+ const style = {
358
+ gridTemplateColumns,
359
+ };
360
+
361
+ if ( 'right' === mediaPosition ) {
362
+ return (
363
+ <div { ...useBlockProps.save( { className, style } ) }>
364
+ <div
365
+ { ...useInnerBlocksProps.save( {
366
+ className: 'wp-block-media-text__content',
367
+ } ) }
368
+ />
369
+ <figure
370
+ className="wp-block-media-text__media"
371
+ style={ backgroundStyles }
372
+ >
373
+ { ( mediaTypeRenders[ mediaType ] || noop )() }
374
+ </figure>
375
+ </div>
376
+ );
377
+ }
378
+ return (
379
+ <div { ...useBlockProps.save( { className, style } ) }>
380
+ <figure
381
+ className="wp-block-media-text__media"
382
+ style={ backgroundStyles }
383
+ >
384
+ { ( mediaTypeRenders[ mediaType ] || noop )() }
385
+ </figure>
386
+ <div
387
+ { ...useInnerBlocksProps.save( {
388
+ className: 'wp-block-media-text__content',
389
+ } ) }
390
+ />
391
+ </div>
392
+ );
393
+ },
394
+ };
395
+
240
396
  // Version with wide as the default alignment.
241
397
  // See: https://github.com/WordPress/gutenberg/pull/48404
242
398
  const v6 = {
@@ -301,7 +457,7 @@ const v6 = {
301
457
  'is-image-fill': imageFill,
302
458
  } );
303
459
  const backgroundStyles = imageFill
304
- ? v6ImageFillStyles( mediaUrl, focalPoint )
460
+ ? v6ToV7ImageFillStyles( mediaUrl, focalPoint )
305
461
  : {};
306
462
 
307
463
  let gridTemplateColumns;
@@ -902,4 +1058,4 @@ const v1 = {
902
1058
  },
903
1059
  };
904
1060
 
905
- export default [ v6, v5, v4, v3, v2, v1 ];
1061
+ export default [ v7, v6, v5, v4, v3, v2, v1 ];
@@ -213,11 +213,11 @@ function MediaTextEdit( {
213
213
  [ isSelected, mediaId ]
214
214
  );
215
215
 
216
- const refMediaContainer = useRef();
216
+ const refMedia = useRef();
217
217
  const imperativeFocalPointPreview = ( value ) => {
218
- const { style } = refMediaContainer.current.resizable;
218
+ const { style } = refMedia.current;
219
219
  const { x, y } = value;
220
- style.backgroundPosition = `${ x * 100 }% ${ y * 100 }%`;
220
+ style.objectPosition = `${ x * 100 }% ${ y * 100 }%`;
221
221
  };
222
222
 
223
223
  const [ temporaryMediaWidth, setTemporaryMediaWidth ] = useState( null );
@@ -243,7 +243,7 @@ function MediaTextEdit( {
243
243
  'is-selected': isSelected,
244
244
  'is-stacked-on-mobile': isStackedOnMobile,
245
245
  [ `is-vertically-aligned-${ verticalAlignment }` ]: verticalAlignment,
246
- 'is-image-fill': imageFill,
246
+ 'is-image-fill-element': imageFill,
247
247
  } );
248
248
  const widthString = `${ temporaryMediaWidth || mediaWidth }%`;
249
249
  const gridTemplateColumns =
@@ -480,7 +480,7 @@ function MediaTextEdit( {
480
480
  onSelectMedia={ onSelectMedia }
481
481
  onWidthChange={ onWidthChange }
482
482
  commitWidthChange={ commitWidthChange }
483
- ref={ refMediaContainer }
483
+ refMedia={ refMedia }
484
484
  enableResize={ blockEditingMode === 'default' }
485
485
  toggleUseFeaturedImage={ toggleUseFeaturedImage }
486
486
  { ...{
@@ -27,7 +27,9 @@
27
27
  }
28
28
 
29
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
+ .wp-block-media-text.is-image-fill .components-placeholder.has-illustration,
31
+ .wp-block-media-text.is-image-fill-element .editor-media-container__resizer,
32
+ .wp-block-media-text.is-image-fill-element .components-placeholder.has-illustration {
31
33
  // The resizer sets an inline height but for the image fill we set it to full height.
32
34
  height: 100% !important;
33
35
  }
@@ -0,0 +1,11 @@
1
+ export function imageFillStyles( url, focalPoint ) {
2
+ return url
3
+ ? {
4
+ objectPosition: focalPoint
5
+ ? `${ Math.round( focalPoint.x * 100 ) }% ${ Math.round(
6
+ focalPoint.y * 100
7
+ ) }%`
8
+ : `50% 50%`,
9
+ }
10
+ : {};
11
+ }