@wordpress/block-library 9.11.0 → 9.12.1-next.082ed6819.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 (272) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/build/block-keyboard-shortcuts/index.js +7 -7
  3. package/build/block-keyboard-shortcuts/index.js.map +1 -1
  4. package/build/button/index.js +1 -1
  5. package/build/button/index.js.map +1 -1
  6. package/build/cover/deprecated.js +140 -4
  7. package/build/cover/deprecated.js.map +1 -1
  8. package/build/cover/edit/block-controls.js +1 -1
  9. package/build/cover/edit/block-controls.js.map +1 -1
  10. package/build/cover/edit/cover-placeholder.js +1 -2
  11. package/build/cover/edit/cover-placeholder.js.map +1 -1
  12. package/build/cover/edit/index.js +23 -23
  13. package/build/cover/edit/index.js.map +1 -1
  14. package/build/cover/index.js +10 -10
  15. package/build/cover/index.js.map +1 -1
  16. package/build/cover/save.js +13 -13
  17. package/build/cover/save.js.map +1 -1
  18. package/build/cover/shared.js +6 -7
  19. package/build/cover/shared.js.map +1 -1
  20. package/build/details/index.js +20 -0
  21. package/build/details/index.js.map +1 -1
  22. package/build/file/edit.js +8 -4
  23. package/build/file/edit.js.map +1 -1
  24. package/build/freeform/modal.js +1 -1
  25. package/build/freeform/modal.js.map +1 -1
  26. package/build/gallery/edit.js +1 -1
  27. package/build/gallery/edit.js.map +1 -1
  28. package/build/heading/index.js +1 -7
  29. package/build/heading/index.js.map +1 -1
  30. package/build/home-link/edit.js +20 -36
  31. package/build/home-link/edit.js.map +1 -1
  32. package/build/image/edit.js +1 -1
  33. package/build/image/edit.js.map +1 -1
  34. package/build/image/image.js +144 -78
  35. package/build/image/image.js.map +1 -1
  36. package/build/image/index.js +1 -1
  37. package/build/latest-posts/edit.js +0 -1
  38. package/build/latest-posts/edit.js.map +1 -1
  39. package/build/lock-unlock.js.map +1 -1
  40. package/build/navigation/edit/index.js +2 -23
  41. package/build/navigation/edit/index.js.map +1 -1
  42. package/build/navigation/use-template-part-area-label.js +6 -8
  43. package/build/navigation/use-template-part-area-label.js.map +1 -1
  44. package/build/page-list/index.js +14 -0
  45. package/build/page-list/index.js.map +1 -1
  46. package/build/paragraph/edit.js +26 -25
  47. package/build/paragraph/edit.js.map +1 -1
  48. package/build/post-content/index.js +13 -0
  49. package/build/post-content/index.js.map +1 -1
  50. package/build/post-template/edit.js +11 -0
  51. package/build/post-template/edit.js.map +1 -1
  52. package/build/post-template/index.js +1 -1
  53. package/build/query/edit/inspector-controls/enhanced-pagination-control.js +1 -3
  54. package/build/query/edit/inspector-controls/enhanced-pagination-control.js.map +1 -1
  55. package/build/query/edit/inspector-controls/index.js +3 -13
  56. package/build/query/edit/inspector-controls/index.js.map +1 -1
  57. package/build/query/edit/pattern-selection-modal.js +0 -3
  58. package/build/query/edit/pattern-selection-modal.js.map +1 -1
  59. package/build/query/edit/query-content.js +10 -12
  60. package/build/query/edit/query-content.js.map +1 -1
  61. package/build/query/index.js +1 -1
  62. package/build/query/utils.js +38 -9
  63. package/build/query/utils.js.map +1 -1
  64. package/build/social-link/edit.js +22 -9
  65. package/build/social-link/edit.js.map +1 -1
  66. package/build/template-part/edit/advanced-controls.js +2 -7
  67. package/build/template-part/edit/advanced-controls.js.map +1 -1
  68. package/build/template-part/edit/index.js +1 -4
  69. package/build/template-part/edit/index.js.map +1 -1
  70. package/build/template-part/edit/selection-modal.js +0 -3
  71. package/build/template-part/edit/selection-modal.js.map +1 -1
  72. package/build/template-part/edit/utils/get-template-part-icon.js +23 -0
  73. package/build/template-part/edit/utils/get-template-part-icon.js.map +1 -0
  74. package/build/template-part/edit/utils/hooks.js +1 -6
  75. package/build/template-part/edit/utils/hooks.js.map +1 -1
  76. package/build/template-part/variations.js +6 -12
  77. package/build/template-part/variations.js.map +1 -1
  78. package/build/video/edit.js +1 -1
  79. package/build/video/edit.js.map +1 -1
  80. package/build/video/tracks-editor.js +135 -123
  81. package/build/video/tracks-editor.js.map +1 -1
  82. package/build-module/block-keyboard-shortcuts/index.js +7 -7
  83. package/build-module/block-keyboard-shortcuts/index.js.map +1 -1
  84. package/build-module/button/index.js +1 -1
  85. package/build-module/button/index.js.map +1 -1
  86. package/build-module/cover/deprecated.js +140 -4
  87. package/build-module/cover/deprecated.js.map +1 -1
  88. package/build-module/cover/edit/block-controls.js +1 -1
  89. package/build-module/cover/edit/block-controls.js.map +1 -1
  90. package/build-module/cover/edit/cover-placeholder.js +1 -2
  91. package/build-module/cover/edit/cover-placeholder.js.map +1 -1
  92. package/build-module/cover/edit/index.js +23 -23
  93. package/build-module/cover/edit/index.js.map +1 -1
  94. package/build-module/cover/index.js +10 -10
  95. package/build-module/cover/index.js.map +1 -1
  96. package/build-module/cover/save.js +13 -13
  97. package/build-module/cover/save.js.map +1 -1
  98. package/build-module/cover/shared.js +6 -7
  99. package/build-module/cover/shared.js.map +1 -1
  100. package/build-module/details/index.js +21 -1
  101. package/build-module/details/index.js.map +1 -1
  102. package/build-module/file/edit.js +8 -4
  103. package/build-module/file/edit.js.map +1 -1
  104. package/build-module/freeform/modal.js +1 -1
  105. package/build-module/freeform/modal.js.map +1 -1
  106. package/build-module/gallery/edit.js +1 -1
  107. package/build-module/gallery/edit.js.map +1 -1
  108. package/build-module/heading/index.js +1 -7
  109. package/build-module/heading/index.js.map +1 -1
  110. package/build-module/home-link/edit.js +23 -39
  111. package/build-module/home-link/edit.js.map +1 -1
  112. package/build-module/image/edit.js +1 -1
  113. package/build-module/image/edit.js.map +1 -1
  114. package/build-module/image/image.js +149 -83
  115. package/build-module/image/image.js.map +1 -1
  116. package/build-module/image/index.js +1 -1
  117. package/build-module/latest-posts/edit.js +0 -1
  118. package/build-module/latest-posts/edit.js.map +1 -1
  119. package/build-module/lock-unlock.js.map +1 -1
  120. package/build-module/navigation/edit/index.js +2 -23
  121. package/build-module/navigation/edit/index.js.map +1 -1
  122. package/build-module/navigation/use-template-part-area-label.js +6 -8
  123. package/build-module/navigation/use-template-part-area-label.js.map +1 -1
  124. package/build-module/page-list/index.js +14 -0
  125. package/build-module/page-list/index.js.map +1 -1
  126. package/build-module/paragraph/edit.js +26 -25
  127. package/build-module/paragraph/edit.js.map +1 -1
  128. package/build-module/post-content/index.js +13 -0
  129. package/build-module/post-content/index.js.map +1 -1
  130. package/build-module/post-template/edit.js +11 -0
  131. package/build-module/post-template/edit.js.map +1 -1
  132. package/build-module/post-template/index.js +1 -1
  133. package/build-module/query/edit/inspector-controls/enhanced-pagination-control.js +1 -3
  134. package/build-module/query/edit/inspector-controls/enhanced-pagination-control.js.map +1 -1
  135. package/build-module/query/edit/inspector-controls/index.js +3 -13
  136. package/build-module/query/edit/inspector-controls/index.js.map +1 -1
  137. package/build-module/query/edit/pattern-selection-modal.js +0 -3
  138. package/build-module/query/edit/pattern-selection-modal.js.map +1 -1
  139. package/build-module/query/edit/query-content.js +10 -12
  140. package/build-module/query/edit/query-content.js.map +1 -1
  141. package/build-module/query/index.js +1 -1
  142. package/build-module/query/utils.js +35 -8
  143. package/build-module/query/utils.js.map +1 -1
  144. package/build-module/social-link/edit.js +24 -11
  145. package/build-module/social-link/edit.js.map +1 -1
  146. package/build-module/template-part/edit/advanced-controls.js +3 -8
  147. package/build-module/template-part/edit/advanced-controls.js.map +1 -1
  148. package/build-module/template-part/edit/index.js +1 -4
  149. package/build-module/template-part/edit/index.js.map +1 -1
  150. package/build-module/template-part/edit/selection-modal.js +0 -3
  151. package/build-module/template-part/edit/selection-modal.js.map +1 -1
  152. package/build-module/template-part/edit/utils/get-template-part-icon.js +15 -0
  153. package/build-module/template-part/edit/utils/get-template-part-icon.js.map +1 -0
  154. package/build-module/template-part/edit/utils/hooks.js +1 -6
  155. package/build-module/template-part/edit/utils/hooks.js.map +1 -1
  156. package/build-module/template-part/variations.js +5 -11
  157. package/build-module/template-part/variations.js.map +1 -1
  158. package/build-module/video/edit.js +1 -1
  159. package/build-module/video/edit.js.map +1 -1
  160. package/build-module/video/tracks-editor.js +136 -124
  161. package/build-module/video/tracks-editor.js.map +1 -1
  162. package/build-style/cover/editor-rtl.css +3 -5
  163. package/build-style/cover/editor.css +3 -5
  164. package/build-style/cover/style-rtl.css +19 -15
  165. package/build-style/cover/style.css +19 -15
  166. package/build-style/editor-rtl.css +19 -30
  167. package/build-style/editor.css +19 -30
  168. package/build-style/group/editor-rtl.css +0 -10
  169. package/build-style/group/editor.css +0 -10
  170. package/build-style/image/editor-rtl.css +4 -0
  171. package/build-style/image/editor.css +4 -0
  172. package/build-style/image/style-rtl.css +0 -2
  173. package/build-style/image/style.css +0 -2
  174. package/build-style/latest-posts/editor-rtl.css +0 -7
  175. package/build-style/latest-posts/editor.css +0 -7
  176. package/build-style/media-text/style-rtl.css +1 -1
  177. package/build-style/media-text/style.css +1 -1
  178. package/build-style/navigation/style-rtl.css +1 -1
  179. package/build-style/navigation/style.css +1 -1
  180. package/build-style/page-list/style-rtl.css +4 -0
  181. package/build-style/page-list/style.css +4 -0
  182. package/build-style/query/editor-rtl.css +0 -4
  183. package/build-style/query/editor.css +0 -4
  184. package/build-style/search/style-rtl.css +3 -3
  185. package/build-style/search/style.css +3 -3
  186. package/build-style/social-link/editor-rtl.css +4 -4
  187. package/build-style/social-link/editor.css +4 -4
  188. package/build-style/style-rtl.css +28 -22
  189. package/build-style/style.css +28 -22
  190. package/build-style/video/editor-rtl.css +8 -0
  191. package/build-style/video/editor.css +8 -0
  192. package/build-types/lock-unlock.d.ts +2 -0
  193. package/build-types/lock-unlock.d.ts.map +1 -0
  194. package/package.json +39 -39
  195. package/src/block-keyboard-shortcuts/index.js +25 -11
  196. package/src/button/index.js +1 -1
  197. package/src/comments/block.json +3 -9
  198. package/src/cover/deprecated.js +182 -4
  199. package/src/cover/edit/block-controls.js +1 -1
  200. package/src/cover/edit/cover-placeholder.js +0 -3
  201. package/src/cover/edit/index.js +42 -27
  202. package/src/cover/editor.scss +4 -5
  203. package/src/cover/index.js +8 -8
  204. package/src/cover/save.js +27 -20
  205. package/src/cover/shared.js +10 -10
  206. package/src/cover/style.scss +40 -16
  207. package/src/cover/test/__snapshots__/edit.native.js.snap +9 -9
  208. package/src/cover/test/__snapshots__/transforms.native.js.snap +4 -4
  209. package/src/cover/test/edit.js +2 -2
  210. package/src/cover/test/edit.native.js +4 -4
  211. package/src/cover/test/transforms.native.js +4 -4
  212. package/src/details/block.json +1 -0
  213. package/src/details/index.js +23 -1
  214. package/src/file/edit.js +9 -3
  215. package/src/freeform/modal.js +1 -1
  216. package/src/gallery/edit.js +1 -1
  217. package/src/group/editor.scss +0 -12
  218. package/src/heading/block.json +1 -7
  219. package/src/home-link/edit.js +27 -45
  220. package/src/home-link/index.php +0 -3
  221. package/src/image/block.json +1 -1
  222. package/src/image/edit.js +1 -1
  223. package/src/image/editor.scss +4 -0
  224. package/src/image/image.js +200 -109
  225. package/src/image/style.scss +0 -1
  226. package/src/image/test/__snapshots__/transforms.native.js.snap +1 -1
  227. package/src/latest-posts/edit.js +0 -1
  228. package/src/latest-posts/editor.scss +0 -11
  229. package/src/media-text/style.scss +1 -1
  230. package/src/media-text/test/__snapshots__/transforms.native.js.snap +2 -2
  231. package/src/navigation/edit/index.js +3 -30
  232. package/src/navigation/index.php +5 -151
  233. package/src/navigation/style.scss +1 -1
  234. package/src/navigation/use-template-part-area-label.js +10 -10
  235. package/src/page-list/block.json +14 -0
  236. package/src/page-list/style.scss +4 -0
  237. package/src/paragraph/edit.js +20 -17
  238. package/src/pattern/index.php +0 -7
  239. package/src/post-content/block.json +14 -1
  240. package/src/post-template/block.json +2 -1
  241. package/src/post-template/edit.js +19 -0
  242. package/src/query/block.json +1 -1
  243. package/src/query/edit/inspector-controls/enhanced-pagination-control.js +3 -5
  244. package/src/query/edit/inspector-controls/index.js +2 -12
  245. package/src/query/edit/pattern-selection-modal.js +0 -3
  246. package/src/query/edit/query-content.js +9 -17
  247. package/src/query/editor.scss +0 -4
  248. package/src/query/index.php +1 -1
  249. package/src/query/test/utils.js +59 -1
  250. package/src/query/utils.js +43 -15
  251. package/src/rss/index.php +11 -8
  252. package/src/search/index.php +2 -2
  253. package/src/search/style.scss +3 -5
  254. package/src/social-link/edit.js +47 -19
  255. package/src/social-link/editor.scss +6 -7
  256. package/src/template-part/edit/advanced-controls.js +13 -13
  257. package/src/template-part/edit/index.js +1 -4
  258. package/src/template-part/edit/selection-modal.js +0 -3
  259. package/src/template-part/edit/utils/get-template-part-icon.js +20 -0
  260. package/src/template-part/edit/utils/hooks.js +2 -7
  261. package/src/template-part/variations.js +4 -16
  262. package/src/video/edit.js +1 -1
  263. package/src/video/editor.scss +9 -0
  264. package/src/video/test/__snapshots__/transforms.native.js.snap +1 -1
  265. package/src/video/tracks-editor.js +157 -141
  266. package/tsconfig.tsbuildinfo +1 -1
  267. package/build/query/edit/inspector-controls/create-new-post-link.js +0 -40
  268. package/build/query/edit/inspector-controls/create-new-post-link.js.map +0 -1
  269. package/build-module/query/edit/inspector-controls/create-new-post-link.js +0 -33
  270. package/build-module/query/edit/inspector-controls/create-new-post-link.js.map +0 -1
  271. package/src/query/edit/inspector-controls/create-new-post-link.js +0 -32
  272. /package/src/{lock-unlock.js → lock-unlock.ts} +0 -0
package/src/file/edit.js CHANGED
@@ -128,15 +128,21 @@ function FileEdit( { attributes, isSelected, setAttributes, clientId } ) {
128
128
  }
129
129
 
130
130
  const isPdf = newMedia.url.endsWith( '.pdf' );
131
+ const pdfAttributes = {
132
+ displayPreview: isPdf
133
+ ? attributes.displayPreview ?? true
134
+ : undefined,
135
+ previewHeight: isPdf ? attributes.previewHeight ?? 600 : undefined,
136
+ };
137
+
131
138
  setAttributes( {
132
139
  href: newMedia.url,
133
140
  fileName: newMedia.title,
134
141
  textLinkHref: newMedia.url,
135
142
  id: newMedia.id,
136
- displayPreview: isPdf ? true : undefined,
137
- previewHeight: isPdf ? 600 : undefined,
138
143
  fileId: `wp-block-file--media-${ clientId }`,
139
144
  blob: undefined,
145
+ ...pdfAttributes,
140
146
  } );
141
147
  setTemporaryURL();
142
148
  }
@@ -201,7 +207,7 @@ function FileEdit( { attributes, isSelected, setAttributes, clientId } ) {
201
207
  labels={ {
202
208
  title: __( 'File' ),
203
209
  instructions: __(
204
- 'Upload a file or pick one from your media library.'
210
+ 'Drag and drop a file, upload, or choose from your library.'
205
211
  ),
206
212
  } }
207
213
  onSelect={ onSelectFile }
@@ -25,7 +25,7 @@ function ModalAuxiliaryActions( { onClick, isModalFullScreen } ) {
25
25
 
26
26
  return (
27
27
  <Button
28
- size="small"
28
+ size="compact"
29
29
  onClick={ onClick }
30
30
  icon={ fullscreen }
31
31
  isPressed={ isModalFullScreen }
@@ -96,7 +96,7 @@ const ALLOWED_MEDIA_TYPES = [ 'image' ];
96
96
 
97
97
  const PLACEHOLDER_TEXT = Platform.isNative
98
98
  ? __( 'Add media' )
99
- : __( 'Drag images, upload new ones or select files from your library.' );
99
+ : __( 'Drag and drop images, upload, or choose from your library.' );
100
100
 
101
101
  const MOBILE_CONTROL_PROPS_RANGE_CONTROL = Platform.isNative
102
102
  ? { type: 'stepper' }
@@ -10,18 +10,6 @@
10
10
  }
11
11
  }
12
12
 
13
- // Reset user select, but the next rule should take precedence for nested
14
- // groups.
15
- :where([data-has-multi-selection]:not([contenteditable="true"]) .wp-block-group > *) {
16
- user-select: initial;
17
- }
18
-
19
- // When we are not multi-selecting, prevent children from capturing the
20
- // selection, which happens when the group is flex and children inlined.
21
- :where([data-has-multi-selection]:not([contenteditable="true"]) .wp-block-group) {
22
- user-select: none;
23
- }
24
-
25
13
  // Place block list appender in the same place content will appear.
26
14
  [data-type="core/group"].is-selected {
27
15
  .block-list-appender {
@@ -37,13 +37,7 @@
37
37
  "color": true,
38
38
  "radius": true,
39
39
  "style": true,
40
- "width": true,
41
- "__experimentalDefaultControls": {
42
- "color": true,
43
- "radius": true,
44
- "style": true,
45
- "width": true
46
- }
40
+ "width": true
47
41
  },
48
42
  "color": {
49
43
  "gradients": true,
@@ -6,15 +6,10 @@ import clsx from 'clsx';
6
6
  /**
7
7
  * WordPress dependencies
8
8
  */
9
- import {
10
- RichText,
11
- useBlockProps,
12
- store as blockEditorStore,
13
- } from '@wordpress/block-editor';
9
+ import { RichText, useBlockProps } from '@wordpress/block-editor';
14
10
  import { __ } from '@wordpress/i18n';
15
- import { useSelect, useDispatch } from '@wordpress/data';
11
+ import { useSelect } from '@wordpress/data';
16
12
  import { store as coreStore } from '@wordpress/core-data';
17
- import { useEffect } from '@wordpress/element';
18
13
 
19
14
  const preventDefault = ( event ) => event.preventDefault();
20
15
 
@@ -24,8 +19,6 @@ export default function HomeEdit( { attributes, setAttributes, context } ) {
24
19
  return select( coreStore ).getEntityRecord( 'root', '__unstableBase' )
25
20
  ?.home;
26
21
  }, [] );
27
- const { __unstableMarkNextChangeAsNotPersistent } =
28
- useDispatch( blockEditorStore );
29
22
 
30
23
  const { textColor, backgroundColor, style } = context;
31
24
  const blockProps = useBlockProps( {
@@ -41,42 +34,31 @@ export default function HomeEdit( { attributes, setAttributes, context } ) {
41
34
  },
42
35
  } );
43
36
 
44
- const { label } = attributes;
45
-
46
- useEffect( () => {
47
- if ( label === undefined ) {
48
- __unstableMarkNextChangeAsNotPersistent();
49
- setAttributes( { label: __( 'Home' ) } );
50
- }
51
- }, [ label ] );
52
-
53
37
  return (
54
- <>
55
- <div { ...blockProps }>
56
- <a
57
- className="wp-block-home-link__content wp-block-navigation-item__content"
58
- href={ homeUrl }
59
- onClick={ preventDefault }
60
- >
61
- <RichText
62
- identifier="label"
63
- className="wp-block-home-link__label"
64
- value={ label }
65
- onChange={ ( labelValue ) => {
66
- setAttributes( { label: labelValue } );
67
- } }
68
- aria-label={ __( 'Home link text' ) }
69
- placeholder={ __( 'Add home link' ) }
70
- withoutInteractiveFormatting
71
- allowedFormats={ [
72
- 'core/bold',
73
- 'core/italic',
74
- 'core/image',
75
- 'core/strikethrough',
76
- ] }
77
- />
78
- </a>
79
- </div>
80
- </>
38
+ <div { ...blockProps }>
39
+ <a
40
+ className="wp-block-home-link__content wp-block-navigation-item__content"
41
+ href={ homeUrl }
42
+ onClick={ preventDefault }
43
+ >
44
+ <RichText
45
+ identifier="label"
46
+ className="wp-block-home-link__label"
47
+ value={ attributes.label ?? __( 'Home' ) }
48
+ onChange={ ( labelValue ) => {
49
+ setAttributes( { label: labelValue } );
50
+ } }
51
+ aria-label={ __( 'Home link text' ) }
52
+ placeholder={ __( 'Add home link' ) }
53
+ withoutInteractiveFormatting
54
+ allowedFormats={ [
55
+ 'core/bold',
56
+ 'core/italic',
57
+ 'core/image',
58
+ 'core/strikethrough',
59
+ ] }
60
+ />
61
+ </a>
62
+ </div>
81
63
  );
82
64
  }
@@ -137,9 +137,6 @@ function block_core_home_link_build_li_wrapper_attributes( $context ) {
137
137
  */
138
138
  function render_block_core_home_link( $attributes, $content, $block ) {
139
139
  if ( empty( $attributes['label'] ) ) {
140
- // Using a fallback for the label attribute allows rendering the block even if no attributes have been set,
141
- // e.g. when using the block as a hooked block.
142
- // Note that the fallback value needs to be kept in sync with the one set in `edit.js` (upon first loading the block in the editor).
143
140
  $attributes['label'] = __( 'Home' );
144
141
  }
145
142
  $aria_current = '';
@@ -4,7 +4,7 @@
4
4
  "name": "core/image",
5
5
  "title": "Image",
6
6
  "category": "media",
7
- "usesContext": [ "allowResize", "imageCrop", "fixedHeight" ],
7
+ "usesContext": [ "allowResize", "imageCrop", "fixedHeight", "postId", "postType", "queryId" ],
8
8
  "description": "Insert an image to make a visual statement.",
9
9
  "keywords": [ "img", "photo", "picture" ],
10
10
  "textdomain": "default",
package/src/image/edit.js CHANGED
@@ -411,7 +411,7 @@ export function ImageEdit( {
411
411
  ! lockUrlControls &&
412
412
  ! isSmallContainer &&
413
413
  __(
414
- 'Upload or drag an image file here, or pick one from your library.'
414
+ 'Drag and drop an image, upload, or choose from your library.'
415
415
  )
416
416
  }
417
417
  style={ {
@@ -159,6 +159,10 @@ figure.wp-block-image:not(.wp-block) {
159
159
  }
160
160
  }
161
161
 
162
+ .wp-block-image__toolbar_content_textarea__container {
163
+ padding: $grid-unit;
164
+ }
165
+
162
166
  .wp-block-image__toolbar_content_textarea {
163
167
  // Corresponds to the size of the textarea in the block inspector.
164
168
  width: 250px;
@@ -10,11 +10,14 @@ import {
10
10
  TextControl,
11
11
  ToolbarButton,
12
12
  ToolbarGroup,
13
- Dropdown,
14
13
  __experimentalToolsPanel as ToolsPanel,
15
14
  __experimentalToolsPanelItem as ToolsPanelItem,
16
15
  __experimentalUseCustomUnits as useCustomUnits,
17
16
  Placeholder,
17
+ MenuItem,
18
+ ToolbarItem,
19
+ DropdownMenu,
20
+ Popover,
18
21
  } from '@wordpress/components';
19
22
  import { useViewportMatch } from '@wordpress/compose';
20
23
  import { useSelect, useDispatch } from '@wordpress/data';
@@ -29,15 +32,15 @@ import {
29
32
  __experimentalUseBorderProps as useBorderProps,
30
33
  __experimentalGetShadowClassesAndStyles as getShadowClassesAndStyles,
31
34
  privateApis as blockEditorPrivateApis,
35
+ BlockSettingsMenuControls,
32
36
  } from '@wordpress/block-editor';
33
37
  import { useEffect, useMemo, useState, useRef } from '@wordpress/element';
34
38
  import { __, _x, sprintf, isRTL } from '@wordpress/i18n';
35
- import { DOWN } from '@wordpress/keycodes';
36
39
  import { getFilename } from '@wordpress/url';
37
40
  import { getBlockBindingsSource, switchToBlockType } from '@wordpress/blocks';
38
- import { crop, overlayText, upload } from '@wordpress/icons';
41
+ import { crop, overlayText, upload, chevronDown } from '@wordpress/icons';
39
42
  import { store as noticesStore } from '@wordpress/notices';
40
- import { store as coreStore } from '@wordpress/core-data';
43
+ import { store as coreStore, useEntityProp } from '@wordpress/core-data';
41
44
 
42
45
  /**
43
46
  * Internal dependencies
@@ -69,6 +72,10 @@ const scaleOptions = [
69
72
  },
70
73
  ];
71
74
 
75
+ const WRITEMODE_POPOVER_PROPS = {
76
+ placement: 'bottom-start',
77
+ };
78
+
72
79
  // If the image has a href, wrap in an <a /> tag to trigger any inherited link element styles.
73
80
  const ImageWrapper = ( { href, children } ) => {
74
81
  if ( ! href ) {
@@ -94,6 +101,150 @@ const ImageWrapper = ( { href, children } ) => {
94
101
  );
95
102
  };
96
103
 
104
+ function ContentOnlyControls( {
105
+ attributes,
106
+ setAttributes,
107
+ lockAltControls,
108
+ lockAltControlsMessage,
109
+ lockTitleControls,
110
+ lockTitleControlsMessage,
111
+ } ) {
112
+ // Use internal state instead of a ref to make sure that the component
113
+ // re-renders when the popover's anchor updates.
114
+ const [ popoverAnchor, setPopoverAnchor ] = useState( null );
115
+ const [ isAltDialogOpen, setIsAltDialogOpen ] = useState( false );
116
+ const [ isTitleDialogOpen, setIsTitleDialogOpen ] = useState( false );
117
+ return (
118
+ <>
119
+ <ToolbarItem ref={ setPopoverAnchor }>
120
+ { ( toggleProps ) => (
121
+ <DropdownMenu
122
+ icon={ chevronDown }
123
+ /* translators: button label text should, if possible, be under 16 characters. */
124
+ label={ __( 'More' ) }
125
+ toggleProps={ {
126
+ ...toggleProps,
127
+ description: __( 'Displays more controls.' ),
128
+ } }
129
+ popoverProps={ WRITEMODE_POPOVER_PROPS }
130
+ >
131
+ { ( { onClose } ) => (
132
+ <>
133
+ <MenuItem
134
+ onClick={ () => {
135
+ setIsAltDialogOpen( true );
136
+ onClose();
137
+ } }
138
+ aria-haspopup="dialog"
139
+ >
140
+ { _x(
141
+ 'Alternative text',
142
+ 'Alternative text for an image. Block toolbar label, a low character count is preferred.'
143
+ ) }
144
+ </MenuItem>
145
+ <MenuItem
146
+ onClick={ () => {
147
+ setIsTitleDialogOpen( true );
148
+ onClose();
149
+ } }
150
+ aria-haspopup="dialog"
151
+ >
152
+ { __( 'Title text' ) }
153
+ </MenuItem>
154
+ </>
155
+ ) }
156
+ </DropdownMenu>
157
+ ) }
158
+ </ToolbarItem>
159
+ { isAltDialogOpen && (
160
+ <Popover
161
+ placement="bottom-start"
162
+ anchor={ popoverAnchor }
163
+ onClose={ () => setIsAltDialogOpen( false ) }
164
+ offset={ 13 }
165
+ variant="toolbar"
166
+ >
167
+ <div className="wp-block-image__toolbar_content_textarea__container">
168
+ <TextareaControl
169
+ className="wp-block-image__toolbar_content_textarea"
170
+ label={ __( 'Alternative text' ) }
171
+ value={ attributes.alt || '' }
172
+ onChange={ ( value ) =>
173
+ setAttributes( { alt: value } )
174
+ }
175
+ disabled={ lockAltControls }
176
+ help={
177
+ lockAltControls ? (
178
+ <>{ lockAltControlsMessage }</>
179
+ ) : (
180
+ <>
181
+ <ExternalLink
182
+ href={
183
+ // translators: Localized tutorial, if one exists. W3C Web Accessibility Initiative link has list of existing translations.
184
+ __(
185
+ 'https://www.w3.org/WAI/tutorials/images/decision-tree/'
186
+ )
187
+ }
188
+ >
189
+ { __(
190
+ 'Describe the purpose of the image.'
191
+ ) }
192
+ </ExternalLink>
193
+ <br />
194
+ { __( 'Leave empty if decorative.' ) }
195
+ </>
196
+ )
197
+ }
198
+ __nextHasNoMarginBottom
199
+ />
200
+ </div>
201
+ </Popover>
202
+ ) }
203
+ { isTitleDialogOpen && (
204
+ <Popover
205
+ placement="bottom-start"
206
+ anchor={ popoverAnchor }
207
+ onClose={ () => setIsTitleDialogOpen( false ) }
208
+ offset={ 13 }
209
+ variant="toolbar"
210
+ >
211
+ <div className="wp-block-image__toolbar_content_textarea__container">
212
+ <TextControl
213
+ __next40pxDefaultSize
214
+ className="wp-block-image__toolbar_content_textarea"
215
+ __nextHasNoMarginBottom
216
+ label={ __( 'Title attribute' ) }
217
+ value={ attributes.title || '' }
218
+ onChange={ ( value ) =>
219
+ setAttributes( {
220
+ title: value,
221
+ } )
222
+ }
223
+ disabled={ lockTitleControls }
224
+ help={
225
+ lockTitleControls ? (
226
+ <>{ lockTitleControlsMessage }</>
227
+ ) : (
228
+ <>
229
+ { __(
230
+ 'Describe the role of this image on the page.'
231
+ ) }
232
+ <ExternalLink href="https://www.w3.org/TR/html52/dom.html#the-title-attribute">
233
+ { __(
234
+ '(Note: many devices and browsers do not display this text.)'
235
+ ) }
236
+ </ExternalLink>
237
+ </>
238
+ )
239
+ }
240
+ />
241
+ </div>
242
+ </Popover>
243
+ ) }
244
+ </>
245
+ );
246
+ }
247
+
97
248
  export default function Image( {
98
249
  temporaryURL,
99
250
  attributes,
@@ -625,112 +776,15 @@ export default function Image( {
625
776
  // Add some extra controls for content attributes when content only mode is active.
626
777
  // With content only mode active, the inspector is hidden, so users need another way
627
778
  // to edit these attributes.
628
- <BlockControls group="other">
629
- <Dropdown
630
- popoverProps={ { position: 'bottom right' } }
631
- renderToggle={ ( { isOpen, onToggle } ) => (
632
- <ToolbarButton
633
- onClick={ onToggle }
634
- aria-haspopup="true"
635
- aria-expanded={ isOpen }
636
- onKeyDown={ ( event ) => {
637
- if ( ! isOpen && event.keyCode === DOWN ) {
638
- event.preventDefault();
639
- onToggle();
640
- }
641
- } }
642
- >
643
- { _x(
644
- 'Alternative text',
645
- 'Alternative text for an image. Block toolbar label, a low character count is preferred.'
646
- ) }
647
- </ToolbarButton>
648
- ) }
649
- renderContent={ () => (
650
- <TextareaControl
651
- className="wp-block-image__toolbar_content_textarea"
652
- label={ __( 'Alternative text' ) }
653
- value={ alt || '' }
654
- onChange={ updateAlt }
655
- disabled={ lockAltControls }
656
- help={
657
- lockAltControls ? (
658
- <>{ lockAltControlsMessage }</>
659
- ) : (
660
- <>
661
- <ExternalLink
662
- href={
663
- // translators: Localized tutorial, if one exists. W3C Web Accessibility Initiative link has list of existing translations.
664
- __(
665
- 'https://www.w3.org/WAI/tutorials/images/decision-tree/'
666
- )
667
- }
668
- >
669
- { __(
670
- 'Describe the purpose of the image.'
671
- ) }
672
- </ExternalLink>
673
- <br />
674
- { __(
675
- 'Leave empty if decorative.'
676
- ) }
677
- </>
678
- )
679
- }
680
- __nextHasNoMarginBottom
681
- />
682
- ) }
779
+ <BlockControls group="block">
780
+ <ContentOnlyControls
781
+ attributes={ attributes }
782
+ setAttributes={ setAttributes }
783
+ lockAltControls={ lockAltControls }
784
+ lockAltControlsMessage={ lockAltControlsMessage }
785
+ lockTitleControls={ lockTitleControls }
786
+ lockTitleControlsMessage={ lockTitleControlsMessage }
683
787
  />
684
- { title && (
685
- <Dropdown
686
- popoverProps={ { position: 'bottom right' } }
687
- renderToggle={ ( { isOpen, onToggle } ) => (
688
- <ToolbarButton
689
- onClick={ onToggle }
690
- aria-haspopup="true"
691
- aria-expanded={ isOpen }
692
- onKeyDown={ ( event ) => {
693
- if (
694
- ! isOpen &&
695
- event.keyCode === DOWN
696
- ) {
697
- event.preventDefault();
698
- onToggle();
699
- }
700
- } }
701
- >
702
- { __( 'Title' ) }
703
- </ToolbarButton>
704
- ) }
705
- renderContent={ () => (
706
- <TextControl
707
- __next40pxDefaultSize
708
- className="wp-block-image__toolbar_content_textarea"
709
- __nextHasNoMarginBottom
710
- label={ __( 'Title attribute' ) }
711
- value={ title || '' }
712
- onChange={ onSetTitle }
713
- disabled={ lockTitleControls }
714
- help={
715
- lockTitleControls ? (
716
- <>{ lockTitleControlsMessage }</>
717
- ) : (
718
- <>
719
- { __(
720
- 'Describe the role of this image on the page.'
721
- ) }
722
- <ExternalLink href="https://www.w3.org/TR/html52/dom.html#the-title-attribute">
723
- { __(
724
- '(Note: many devices and browsers do not display this text.)'
725
- ) }
726
- </ExternalLink>
727
- </>
728
- )
729
- }
730
- />
731
- ) }
732
- />
733
- ) }
734
788
  </BlockControls>
735
789
  ) }
736
790
  <InspectorControls>
@@ -842,6 +896,16 @@ export default function Image( {
842
896
  const shadowProps = getShadowClassesAndStyles( attributes );
843
897
  const isRounded = attributes.className?.includes( 'is-style-rounded' );
844
898
 
899
+ const { postType, postId, queryId } = context;
900
+ const isDescendentOfQueryLoop = Number.isFinite( queryId );
901
+
902
+ const [ , setFeaturedImage ] = useEntityProp(
903
+ 'postType',
904
+ postType,
905
+ 'featured_media',
906
+ postId
907
+ );
908
+
845
909
  let img =
846
910
  temporaryURL && hasImageErrored ? (
847
911
  // Show a placeholder during upload when the blob URL can't be loaded. This can
@@ -1043,10 +1107,37 @@ export default function Image( {
1043
1107
  );
1044
1108
  }
1045
1109
 
1110
+ /**
1111
+ * Set the post's featured image with the current image.
1112
+ */
1113
+ const setPostFeatureImage = () => {
1114
+ setFeaturedImage( id );
1115
+ createSuccessNotice( __( 'Post featured image updated.' ), {
1116
+ type: 'snackbar',
1117
+ } );
1118
+ };
1119
+
1120
+ const featuredImageControl = (
1121
+ <BlockSettingsMenuControls>
1122
+ { ( { selectedClientIds } ) =>
1123
+ selectedClientIds.length === 1 &&
1124
+ ! isDescendentOfQueryLoop &&
1125
+ postId &&
1126
+ id &&
1127
+ clientId === selectedClientIds[ 0 ] && (
1128
+ <MenuItem onClick={ setPostFeatureImage }>
1129
+ { __( 'Set featured image' ) }
1130
+ </MenuItem>
1131
+ )
1132
+ }
1133
+ </BlockSettingsMenuControls>
1134
+ );
1135
+
1046
1136
  return (
1047
1137
  <>
1048
1138
  { mediaReplaceFlow }
1049
1139
  { controls }
1140
+ { featuredImageControl }
1050
1141
  { img }
1051
1142
 
1052
1143
  <Caption
@@ -9,7 +9,6 @@
9
9
  max-width: 100%;
10
10
  vertical-align: bottom;
11
11
  box-sizing: border-box;
12
- width: fit-content;
13
12
 
14
13
  @media (prefers-reduced-motion: no-preference) {
15
14
  &.hide {
@@ -12,7 +12,7 @@ exports[`Image block transformations to Columns block 1`] = `
12
12
 
13
13
  exports[`Image block transformations to Cover block 1`] = `
14
14
  "<!-- wp:cover {"url":"https://cldup.com/cXyG__fTLN.jpg","id":1,"dimRatio":50,"style":{"color":{}}} -->
15
- <div class="wp-block-cover"><span aria-hidden="true" class="wp-block-cover__background has-background-dim"></span><img class="wp-block-cover__image-background wp-image-1" alt="" src="https://cldup.com/cXyG__fTLN.jpg" data-object-fit="cover"/><div class="wp-block-cover__inner-container"><!-- wp:paragraph {"align":"center","fontSize":"large"} -->
15
+ <div class="wp-block-cover"><img class="wp-block-cover__image-background wp-image-1" alt="" src="https://cldup.com/cXyG__fTLN.jpg" data-object-fit="cover"/><span aria-hidden="true" class="wp-block-cover__background has-background-dim"></span><div class="wp-block-cover__inner-container"><!-- wp:paragraph {"align":"center","fontSize":"large"} -->
16
16
  <p class="has-text-align-center has-large-font-size">Mountain</p>
17
17
  <!-- /wp:paragraph --></div></div>
18
18
  <!-- /wp:cover -->"
@@ -238,7 +238,6 @@ export default function LatestPostsEdit( { attributes, setAttributes } ) {
238
238
  />
239
239
  { displayPostContent && (
240
240
  <RadioControl
241
- className="wp-block-latest-posts__post-content-radio"
242
241
  label={ __( 'Show' ) }
243
242
  selected={ displayPostContentRadio }
244
243
  options={ [
@@ -18,14 +18,3 @@
18
18
  padding-left: 0;
19
19
  }
20
20
  }
21
-
22
- // Apply the same styles that would be applied to
23
- // ".block-editor-block-inspector .components-base-control"
24
- // (see packages/block-editor/src/components/block-inspector/style.scss)
25
- .wp-block-latest-posts__post-content-radio {
26
- margin-bottom: #{ $grid-unit-30 };
27
-
28
- &:last-child {
29
- margin-bottom: $grid-unit-10;
30
- }
31
- }
@@ -69,7 +69,7 @@
69
69
  }
70
70
 
71
71
  .wp-block-media-text__media a {
72
- display: inline-block;
72
+ display: block;
73
73
  }
74
74
 
75
75
  .wp-block-media-text__media img,
@@ -14,7 +14,7 @@ exports[`Media & Text block transformations with Image to Columns block 1`] = `
14
14
 
15
15
  exports[`Media & Text block transformations with Image to Cover block 1`] = `
16
16
  "<!-- wp:cover {"url":"https://cldup.com/cXyG__fTLN.jpg","id":4674,"dimRatio":50,"align":"wide"} -->
17
- <div class="wp-block-cover alignwide"><span aria-hidden="true" class="wp-block-cover__background has-background-dim"></span><img class="wp-block-cover__image-background wp-image-4674" alt="" src="https://cldup.com/cXyG__fTLN.jpg" data-object-fit="cover"/><div class="wp-block-cover__inner-container"><!-- wp:paragraph {"className":"has-large-font-size"} -->
17
+ <div class="wp-block-cover alignwide"><img class="wp-block-cover__image-background wp-image-4674" alt="" src="https://cldup.com/cXyG__fTLN.jpg" data-object-fit="cover"/><span aria-hidden="true" class="wp-block-cover__background has-background-dim"></span><div class="wp-block-cover__inner-container"><!-- wp:paragraph {"className":"has-large-font-size"} -->
18
18
  <p class="has-large-font-size">Mountain</p>
19
19
  <!-- /wp:paragraph --></div></div>
20
20
  <!-- /wp:cover -->"
@@ -50,7 +50,7 @@ exports[`Media & Text block transformations with Video to Columns block 1`] = `
50
50
 
51
51
  exports[`Media & Text block transformations with Video to Cover block 1`] = `
52
52
  "<!-- wp:cover {"url":"https://i.cloudup.com/YtZFJbuQCE.mov","id":4675,"dimRatio":50,"backgroundType":"video","align":"wide"} -->
53
- <div class="wp-block-cover alignwide"><span aria-hidden="true" class="wp-block-cover__background has-background-dim"></span><video class="wp-block-cover__video-background intrinsic-ignore" autoplay muted loop playsinline src="https://i.cloudup.com/YtZFJbuQCE.mov" data-object-fit="cover"></video><div class="wp-block-cover__inner-container"><!-- wp:paragraph {"className":"has-large-font-size"} -->
53
+ <div class="wp-block-cover alignwide"><video class="wp-block-cover__video-background intrinsic-ignore" autoplay muted loop playsinline src="https://i.cloudup.com/YtZFJbuQCE.mov" data-object-fit="cover"></video><span aria-hidden="true" class="wp-block-cover__background has-background-dim"></span><div class="wp-block-cover__inner-container"><!-- wp:paragraph {"className":"has-large-font-size"} -->
54
54
  <p class="has-large-font-size">Cloudup</p>
55
55
  <!-- /wp:paragraph --></div></div>
56
56
  <!-- /wp:cover -->"