@wordpress/block-library 9.10.0 → 9.12.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 (307) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/README.md +10 -5
  3. package/build/archives/index.js +6 -0
  4. package/build/archives/index.js.map +1 -1
  5. package/build/avatar/hooks.js +2 -3
  6. package/build/avatar/hooks.js.map +1 -1
  7. package/build/button/get-updated-link-attributes.js +1 -1
  8. package/build/button/get-updated-link-attributes.js.map +1 -1
  9. package/build/button/index.js +1 -1
  10. package/build/button/index.js.map +1 -1
  11. package/build/comments/index.js +12 -0
  12. package/build/comments/index.js.map +1 -1
  13. package/build/cover/constants.js +8 -0
  14. package/build/cover/constants.js.map +1 -0
  15. package/build/cover/deprecated.js +140 -4
  16. package/build/cover/deprecated.js.map +1 -1
  17. package/build/cover/edit/block-controls.js +1 -1
  18. package/build/cover/edit/block-controls.js.map +1 -1
  19. package/build/cover/edit/cover-placeholder.js +1 -2
  20. package/build/cover/edit/cover-placeholder.js.map +1 -1
  21. package/build/cover/edit/index.js +42 -21
  22. package/build/cover/edit/index.js.map +1 -1
  23. package/build/cover/edit/inspector-controls.js +40 -2
  24. package/build/cover/edit/inspector-controls.js.map +1 -1
  25. package/build/cover/index.js +3 -0
  26. package/build/cover/index.js.map +1 -1
  27. package/build/cover/save.js +16 -14
  28. package/build/cover/save.js.map +1 -1
  29. package/build/details/index.js +1 -0
  30. package/build/details/index.js.map +1 -1
  31. package/build/file/edit.js +2 -3
  32. package/build/file/edit.js.map +1 -1
  33. package/build/gallery/constants.js +2 -1
  34. package/build/gallery/constants.js.map +1 -1
  35. package/build/gallery/edit.js +12 -3
  36. package/build/gallery/edit.js.map +1 -1
  37. package/build/gallery/utils.js +26 -5
  38. package/build/gallery/utils.js.map +1 -1
  39. package/build/html/edit.js +5 -1
  40. package/build/html/edit.js.map +1 -1
  41. package/build/html/preview.js +2 -2
  42. package/build/html/preview.js.map +1 -1
  43. package/build/image/edit.js +1 -1
  44. package/build/image/edit.js.map +1 -1
  45. package/build/image/image.js +144 -78
  46. package/build/image/image.js.map +1 -1
  47. package/build/image/index.js +1 -1
  48. package/build/latest-posts/edit.js +3 -9
  49. package/build/latest-posts/edit.js.map +1 -1
  50. package/build/lock-unlock.js.map +1 -1
  51. package/build/navigation/edit/menu-inspector-controls.js +1 -1
  52. package/build/navigation/edit/menu-inspector-controls.js.map +1 -1
  53. package/build/navigation/edit/navigation-menu-selector.js +2 -2
  54. package/build/navigation/edit/navigation-menu-selector.js.map +1 -1
  55. package/build/paragraph/edit.js +2 -2
  56. package/build/paragraph/edit.js.map +1 -1
  57. package/build/post-content/index.js +13 -0
  58. package/build/post-content/index.js.map +1 -1
  59. package/build/post-featured-image/edit.js +1 -1
  60. package/build/post-featured-image/edit.js.map +1 -1
  61. package/build/post-template/edit.js +11 -0
  62. package/build/post-template/edit.js.map +1 -1
  63. package/build/post-template/index.js +1 -1
  64. package/build/post-time-to-read/edit.js +2 -2
  65. package/build/post-time-to-read/edit.js.map +1 -1
  66. package/build/query/edit/inspector-controls/index.js +2 -2
  67. package/build/query/edit/inspector-controls/index.js.map +1 -1
  68. package/build/query/edit/inspector-controls/order-control.js +2 -2
  69. package/build/query/edit/inspector-controls/order-control.js.map +1 -1
  70. package/build/query/edit/pattern-selection-modal.js +0 -3
  71. package/build/query/edit/pattern-selection-modal.js.map +1 -1
  72. package/build/query/edit/query-content.js +10 -12
  73. package/build/query/edit/query-content.js.map +1 -1
  74. package/build/query/index.js +1 -1
  75. package/build/query/utils.js +32 -1
  76. package/build/query/utils.js.map +1 -1
  77. package/build/query-title/edit.js +1 -1
  78. package/build/query-title/edit.js.map +1 -1
  79. package/build/search/edit.js +19 -14
  80. package/build/search/edit.js.map +1 -1
  81. package/build/separator/transforms.js +12 -0
  82. package/build/separator/transforms.js.map +1 -1
  83. package/build/social-links/edit.js +0 -1
  84. package/build/social-links/edit.js.map +1 -1
  85. package/build/spacer/index.js +2 -0
  86. package/build/spacer/index.js.map +1 -1
  87. package/build/spacer/transforms.js +27 -0
  88. package/build/spacer/transforms.js.map +1 -0
  89. package/build/table/edit.js +0 -1
  90. package/build/table/edit.js.map +1 -1
  91. package/build/table-of-contents/edit.js +2 -7
  92. package/build/table-of-contents/edit.js.map +1 -1
  93. package/build/template-part/edit/index.js +2 -5
  94. package/build/template-part/edit/index.js.map +1 -1
  95. package/build/template-part/edit/selection-modal.js +0 -3
  96. package/build/template-part/edit/selection-modal.js.map +1 -1
  97. package/build/video/edit.js +1 -1
  98. package/build/video/edit.js.map +1 -1
  99. package/build/video/tracks-editor.js +1 -3
  100. package/build/video/tracks-editor.js.map +1 -1
  101. package/build-module/archives/index.js +6 -0
  102. package/build-module/archives/index.js.map +1 -1
  103. package/build-module/avatar/hooks.js +2 -3
  104. package/build-module/avatar/hooks.js.map +1 -1
  105. package/build-module/button/get-updated-link-attributes.js +1 -1
  106. package/build-module/button/get-updated-link-attributes.js.map +1 -1
  107. package/build-module/button/index.js +1 -1
  108. package/build-module/button/index.js.map +1 -1
  109. package/build-module/comments/index.js +12 -0
  110. package/build-module/comments/index.js.map +1 -1
  111. package/build-module/cover/constants.js +2 -0
  112. package/build-module/cover/constants.js.map +1 -0
  113. package/build-module/cover/deprecated.js +140 -4
  114. package/build-module/cover/deprecated.js.map +1 -1
  115. package/build-module/cover/edit/block-controls.js +1 -1
  116. package/build-module/cover/edit/block-controls.js.map +1 -1
  117. package/build-module/cover/edit/cover-placeholder.js +1 -2
  118. package/build-module/cover/edit/cover-placeholder.js.map +1 -1
  119. package/build-module/cover/edit/index.js +42 -21
  120. package/build-module/cover/edit/index.js.map +1 -1
  121. package/build-module/cover/edit/inspector-controls.js +41 -3
  122. package/build-module/cover/edit/inspector-controls.js.map +1 -1
  123. package/build-module/cover/index.js +3 -0
  124. package/build-module/cover/index.js.map +1 -1
  125. package/build-module/cover/save.js +16 -14
  126. package/build-module/cover/save.js.map +1 -1
  127. package/build-module/details/index.js +1 -0
  128. package/build-module/details/index.js.map +1 -1
  129. package/build-module/file/edit.js +2 -3
  130. package/build-module/file/edit.js.map +1 -1
  131. package/build-module/gallery/constants.js +1 -0
  132. package/build-module/gallery/constants.js.map +1 -1
  133. package/build-module/gallery/edit.js +15 -6
  134. package/build-module/gallery/edit.js.map +1 -1
  135. package/build-module/gallery/utils.js +27 -6
  136. package/build-module/gallery/utils.js.map +1 -1
  137. package/build-module/html/edit.js +6 -2
  138. package/build-module/html/edit.js.map +1 -1
  139. package/build-module/html/preview.js +2 -2
  140. package/build-module/html/preview.js.map +1 -1
  141. package/build-module/image/edit.js +1 -1
  142. package/build-module/image/edit.js.map +1 -1
  143. package/build-module/image/image.js +149 -83
  144. package/build-module/image/image.js.map +1 -1
  145. package/build-module/image/index.js +1 -1
  146. package/build-module/latest-posts/edit.js +3 -9
  147. package/build-module/latest-posts/edit.js.map +1 -1
  148. package/build-module/lock-unlock.js.map +1 -1
  149. package/build-module/navigation/edit/menu-inspector-controls.js +1 -3
  150. package/build-module/navigation/edit/menu-inspector-controls.js.map +1 -1
  151. package/build-module/navigation/edit/navigation-menu-selector.js +2 -2
  152. package/build-module/navigation/edit/navigation-menu-selector.js.map +1 -1
  153. package/build-module/paragraph/edit.js +2 -2
  154. package/build-module/paragraph/edit.js.map +1 -1
  155. package/build-module/post-content/index.js +13 -0
  156. package/build-module/post-content/index.js.map +1 -1
  157. package/build-module/post-featured-image/edit.js +1 -1
  158. package/build-module/post-featured-image/edit.js.map +1 -1
  159. package/build-module/post-template/edit.js +11 -0
  160. package/build-module/post-template/edit.js.map +1 -1
  161. package/build-module/post-template/index.js +1 -1
  162. package/build-module/post-time-to-read/edit.js +2 -2
  163. package/build-module/post-time-to-read/edit.js.map +1 -1
  164. package/build-module/query/edit/inspector-controls/index.js +2 -2
  165. package/build-module/query/edit/inspector-controls/index.js.map +1 -1
  166. package/build-module/query/edit/inspector-controls/order-control.js +2 -2
  167. package/build-module/query/edit/inspector-controls/order-control.js.map +1 -1
  168. package/build-module/query/edit/pattern-selection-modal.js +0 -3
  169. package/build-module/query/edit/pattern-selection-modal.js.map +1 -1
  170. package/build-module/query/edit/query-content.js +10 -12
  171. package/build-module/query/edit/query-content.js.map +1 -1
  172. package/build-module/query/index.js +1 -1
  173. package/build-module/query/utils.js +29 -0
  174. package/build-module/query/utils.js.map +1 -1
  175. package/build-module/query-title/edit.js +2 -2
  176. package/build-module/query-title/edit.js.map +1 -1
  177. package/build-module/search/edit.js +20 -15
  178. package/build-module/search/edit.js.map +1 -1
  179. package/build-module/separator/transforms.js +12 -0
  180. package/build-module/separator/transforms.js.map +1 -1
  181. package/build-module/social-links/edit.js +0 -1
  182. package/build-module/social-links/edit.js.map +1 -1
  183. package/build-module/spacer/index.js +2 -0
  184. package/build-module/spacer/index.js.map +1 -1
  185. package/build-module/spacer/transforms.js +20 -0
  186. package/build-module/spacer/transforms.js.map +1 -0
  187. package/build-module/table/edit.js +0 -1
  188. package/build-module/table/edit.js.map +1 -1
  189. package/build-module/table-of-contents/edit.js +2 -7
  190. package/build-module/table-of-contents/edit.js.map +1 -1
  191. package/build-module/template-part/edit/index.js +2 -5
  192. package/build-module/template-part/edit/index.js.map +1 -1
  193. package/build-module/template-part/edit/selection-modal.js +0 -3
  194. package/build-module/template-part/edit/selection-modal.js.map +1 -1
  195. package/build-module/video/edit.js +1 -1
  196. package/build-module/video/edit.js.map +1 -1
  197. package/build-module/video/tracks-editor.js +2 -4
  198. package/build-module/video/tracks-editor.js.map +1 -1
  199. package/build-style/archives/editor-rtl.css +5 -0
  200. package/build-style/archives/editor.css +5 -0
  201. package/build-style/button/style-rtl.css +3 -0
  202. package/build-style/button/style.css +3 -0
  203. package/build-style/comments/editor-rtl.css +4 -0
  204. package/build-style/comments/editor.css +4 -0
  205. package/build-style/comments/style-rtl.css +4 -0
  206. package/build-style/comments/style.css +4 -0
  207. package/build-style/cover/editor-rtl.css +3 -5
  208. package/build-style/cover/editor.css +3 -5
  209. package/build-style/cover/style-rtl.css +19 -10
  210. package/build-style/cover/style.css +19 -10
  211. package/build-style/editor-rtl.css +17 -12
  212. package/build-style/editor.css +17 -12
  213. package/build-style/image/editor-rtl.css +4 -0
  214. package/build-style/image/editor.css +4 -0
  215. package/build-style/latest-posts/editor-rtl.css +0 -7
  216. package/build-style/latest-posts/editor.css +0 -7
  217. package/build-style/media-text/style-rtl.css +1 -1
  218. package/build-style/media-text/style.css +1 -1
  219. package/build-style/navigation/editor-rtl.css +1 -0
  220. package/build-style/navigation/editor.css +1 -0
  221. package/build-style/style-rtl.css +27 -11
  222. package/build-style/style.css +27 -11
  223. package/build-types/lock-unlock.d.ts +2 -0
  224. package/build-types/lock-unlock.d.ts.map +1 -0
  225. package/package.json +41 -40
  226. package/src/archives/block.json +6 -0
  227. package/src/archives/editor.scss +8 -0
  228. package/src/avatar/hooks.js +2 -3
  229. package/src/avatar/index.php +4 -5
  230. package/src/button/get-updated-link-attributes.js +1 -1
  231. package/src/button/index.js +1 -1
  232. package/src/button/style.scss +3 -0
  233. package/src/button/test/get-updated-link-attributes.js +15 -0
  234. package/src/comment-author-avatar/index.php +1 -1
  235. package/src/comments/block.json +12 -0
  236. package/src/comments/style.scss +4 -1
  237. package/src/cover/block.json +3 -0
  238. package/src/cover/constants.js +1 -0
  239. package/src/cover/deprecated.js +182 -4
  240. package/src/cover/edit/block-controls.js +1 -1
  241. package/src/cover/edit/cover-placeholder.js +0 -3
  242. package/src/cover/edit/index.js +57 -24
  243. package/src/cover/edit/inspector-controls.js +46 -1
  244. package/src/cover/editor.scss +4 -5
  245. package/src/cover/save.js +29 -20
  246. package/src/cover/style.scss +40 -10
  247. package/src/cover/test/__snapshots__/edit.native.js.snap +9 -9
  248. package/src/cover/test/__snapshots__/transforms.native.js.snap +4 -4
  249. package/src/cover/test/edit.js +1 -3
  250. package/src/cover/test/edit.native.js +4 -4
  251. package/src/cover/test/transforms.native.js +4 -4
  252. package/src/details/block.json +1 -0
  253. package/src/file/edit.js +2 -3
  254. package/src/gallery/constants.js +1 -0
  255. package/src/gallery/edit.js +26 -3
  256. package/src/gallery/utils.js +23 -2
  257. package/src/html/edit.js +7 -1
  258. package/src/html/preview.js +3 -2
  259. package/src/image/block.json +1 -1
  260. package/src/image/edit.js +1 -1
  261. package/src/image/editor.scss +4 -0
  262. package/src/image/image.js +200 -109
  263. package/src/image/test/__snapshots__/transforms.native.js.snap +1 -1
  264. package/src/latest-posts/edit.js +3 -8
  265. package/src/latest-posts/editor.scss +0 -11
  266. package/src/latest-posts/index.php +1 -1
  267. package/src/media-text/style.scss +1 -1
  268. package/src/media-text/test/__snapshots__/transforms.native.js.snap +2 -2
  269. package/src/navigation/edit/menu-inspector-controls.js +2 -2
  270. package/src/navigation/edit/navigation-menu-selector.js +2 -2
  271. package/src/navigation/editor.scss +1 -0
  272. package/src/navigation/index.php +1 -1
  273. package/src/paragraph/edit.js +2 -2
  274. package/src/post-content/block.json +14 -1
  275. package/src/post-featured-image/edit.js +1 -1
  276. package/src/post-template/block.json +2 -1
  277. package/src/post-template/edit.js +19 -0
  278. package/src/post-time-to-read/edit.js +2 -2
  279. package/src/post-time-to-read/index.php +1 -1
  280. package/src/query/block.json +1 -1
  281. package/src/query/edit/inspector-controls/index.js +2 -2
  282. package/src/query/edit/inspector-controls/order-control.js +2 -2
  283. package/src/query/edit/pattern-selection-modal.js +0 -3
  284. package/src/query/edit/query-content.js +9 -17
  285. package/src/query/test/utils.js +59 -1
  286. package/src/query/utils.js +29 -0
  287. package/src/query-title/edit.js +2 -2
  288. package/src/rss/index.php +1 -1
  289. package/src/search/edit.js +28 -25
  290. package/src/search/index.php +2 -2
  291. package/src/separator/test/__snapshots__/transforms.native.js.snap +6 -0
  292. package/src/separator/test/transforms.native.js +1 -1
  293. package/src/separator/transforms.js +11 -0
  294. package/src/social-links/edit.js +0 -1
  295. package/src/spacer/index.js +2 -0
  296. package/src/spacer/test/__snapshots__/transforms.native.js.snap +6 -0
  297. package/src/spacer/test/transforms.native.js +1 -1
  298. package/src/spacer/transforms.js +20 -0
  299. package/src/table/edit.js +0 -1
  300. package/src/table-of-contents/edit.js +2 -6
  301. package/src/template-part/edit/index.js +2 -5
  302. package/src/template-part/edit/selection-modal.js +0 -3
  303. package/src/video/edit.js +1 -1
  304. package/src/video/test/__snapshots__/transforms.native.js.snap +1 -1
  305. package/src/video/tracks-editor.js +2 -4
  306. package/tsconfig.tsbuildinfo +1 -1
  307. /package/src/{lock-unlock.js → lock-unlock.ts} +0 -0
@@ -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
@@ -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 -->"
@@ -155,15 +155,11 @@ export default function LatestPostsEdit( { attributes, setAttributes } ) {
155
155
  );
156
156
 
157
157
  // If a user clicks to a link prevent redirection and show a warning.
158
- const { createWarningNotice, removeNotice } = useDispatch( noticeStore );
159
- let noticeId;
158
+ const { createWarningNotice } = useDispatch( noticeStore );
160
159
  const showRedirectionPreventedNotice = ( event ) => {
161
160
  event.preventDefault();
162
- // Remove previous warning if any, to show one at a time per block.
163
- removeNotice( noticeId );
164
- noticeId = `block-library/core/latest-posts/redirection-prevented/${ instanceId }`;
165
161
  createWarningNotice( __( 'Links are disabled in the editor.' ), {
166
- id: noticeId,
162
+ id: `block-library/core/latest-posts/redirection-prevented/${ instanceId }`,
167
163
  type: 'snackbar',
168
164
  } );
169
165
  };
@@ -242,7 +238,6 @@ export default function LatestPostsEdit( { attributes, setAttributes } ) {
242
238
  />
243
239
  { displayPostContent && (
244
240
  <RadioControl
245
- className="wp-block-latest-posts__post-content-radio"
246
241
  label={ __( 'Show' ) }
247
242
  selected={ displayPostContentRadio }
248
243
  options={ [
@@ -593,7 +588,7 @@ export default function LatestPostsEdit( { attributes, setAttributes } ) {
593
588
  { displayAuthor && currentAuthor && (
594
589
  <div className="wp-block-latest-posts__post-author">
595
590
  { sprintf(
596
- /* translators: byline. %s: current author. */
591
+ /* translators: byline. %s: author. */
597
592
  __( 'by %s' ),
598
593
  currentAuthor.name
599
594
  ) }
@@ -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
- }
@@ -123,7 +123,7 @@ function render_block_core_latest_posts( $attributes ) {
123
123
  if ( isset( $attributes['displayAuthor'] ) && $attributes['displayAuthor'] ) {
124
124
  $author_display_name = get_the_author_meta( 'display_name', $post->post_author );
125
125
 
126
- /* translators: byline. %s: current author. */
126
+ /* translators: byline. %s: author. */
127
127
  $byline = sprintf( __( 'by %s' ), $author_display_name );
128
128
 
129
129
  if ( ! empty( $author_display_name ) ) {
@@ -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 -->"
@@ -26,8 +26,8 @@ import LeafMoreMenu from './leaf-more-menu';
26
26
  import { updateAttributes } from '../../navigation-link/update-attributes';
27
27
  import { LinkUI } from '../../navigation-link/link-ui';
28
28
 
29
- /* translators: %s: The name of a menu. */
30
- const actionLabel = __( "Switch to '%s'" );
29
+ const actionLabel =
30
+ /* translators: %s: The name of a menu. */ __( "Switch to '%s'" );
31
31
  const BLOCKS_WITH_LINK_UI_SUPPORT = [
32
32
  'core/navigation-link',
33
33
  'core/navigation-submenu',
@@ -21,7 +21,7 @@ import useNavigationEntities from '../use-navigation-entities';
21
21
 
22
22
  function buildMenuLabel( title, id, status ) {
23
23
  if ( ! title ) {
24
- /* translators: %s is the index of the menu in the list of menus. */
24
+ /* translators: %s: the index of the menu in the list of menus. */
25
25
  return sprintf( __( '(no title %s)' ), id );
26
26
  }
27
27
 
@@ -30,7 +30,7 @@ function buildMenuLabel( title, id, status ) {
30
30
  }
31
31
 
32
32
  return sprintf(
33
- // translators: %1s: title of the menu; %2s: status of the menu (draft, pending, etc.).
33
+ // translators: 1: title of the menu. 2: status of the menu (draft, pending, etc.).
34
34
  __( '%1$s (%2$s)' ),
35
35
  decodeEntities( title ),
36
36
  status
@@ -203,6 +203,7 @@ $color-control-label-height: 20px;
203
203
  .wp-block-navigation .wp-block + .block-list-appender .block-editor-button-block-appender {
204
204
  background-color: $gray-900;
205
205
  color: $white;
206
+ height: $button-size-small;
206
207
 
207
208
  // This needs specificity to override an inherited padding.
208
209
  // That source padding in turn has high specificity to protect
@@ -813,7 +813,7 @@ function block_core_navigation_add_directives_to_submenu( $tags, $block_attribut
813
813
  ) ) {
814
814
  // Add directives to the parent `<li>`.
815
815
  $tags->set_attribute( 'data-wp-interactive', 'core/navigation' );
816
- $tags->set_attribute( 'data-wp-context', '{ "submenuOpenedBy": { "click": false, "hover": false, "focus": false }, "type": "submenu" }' );
816
+ $tags->set_attribute( 'data-wp-context', '{ "submenuOpenedBy": { "click": false, "hover": false, "focus": false }, "type": "submenu", "modal": null }' );
817
817
  $tags->set_attribute( 'data-wp-watch', 'callbacks.initMenu' );
818
818
  $tags->set_attribute( 'data-wp-on--focusout', 'actions.handleMenuFocusout' );
819
819
  $tags->set_attribute( 'data-wp-on--keydown', 'actions.handleMenuKeydown' );
@@ -66,7 +66,7 @@ function DropCapControl( { clientId, attributes, setAttributes } ) {
66
66
  } else if ( dropCap ) {
67
67
  helpText = __( 'Showing large initial letter.' );
68
68
  } else {
69
- helpText = __( 'Toggle to show a large initial letter.' );
69
+ helpText = __( 'Show a large initial letter.' );
70
70
  }
71
71
 
72
72
  return (
@@ -83,7 +83,7 @@ function DropCapControl( { clientId, attributes, setAttributes } ) {
83
83
  checked={ !! dropCap }
84
84
  onChange={ () => setAttributes( { dropCap: ! dropCap } ) }
85
85
  help={ helpText }
86
- disabled={ hasDropCapDisabled( align ) ? true : false }
86
+ disabled={ hasDropCapDisabled( align ) }
87
87
  />
88
88
  </ToolsPanelItem>
89
89
  );
@@ -27,6 +27,7 @@
27
27
  "spacing": {
28
28
  "blockGap": true,
29
29
  "padding": true,
30
+ "margin": true,
30
31
  "__experimentalDefaultControls": {
31
32
  "margin": false,
32
33
  "padding": false
@@ -52,8 +53,20 @@
52
53
  "__experimentalDefaultControls": {
53
54
  "fontSize": true
54
55
  }
56
+ },
57
+ "__experimentalBorder": {
58
+ "radius": true,
59
+ "color": true,
60
+ "width": true,
61
+ "style": true,
62
+ "__experimentalDefaultControls": {
63
+ "radius": true,
64
+ "color": true,
65
+ "width": true,
66
+ "style": true
67
+ }
55
68
  }
56
69
  },
57
70
  "style": "wp-block-post-content",
58
71
  "editorStyle": "wp-block-post-content-editor"
59
- }
72
+ }
@@ -207,7 +207,7 @@ export default function PostFeaturedImageEdit( {
207
207
  label={
208
208
  postType?.labels.singular_name
209
209
  ? sprintf(
210
- // translators: %s: Name of the post type e.g: "Page".
210
+ // translators: %s: Name of the post type e.g: "post".
211
211
  __( 'Link to %s' ),
212
212
  postType.labels.singular_name
213
213
  )
@@ -13,7 +13,8 @@
13
13
  "displayLayout",
14
14
  "templateSlug",
15
15
  "previewPostType",
16
- "enhancedPagination"
16
+ "enhancedPagination",
17
+ "postType"
17
18
  ],
18
19
  "supports": {
19
20
  "reusable": false,
@@ -119,6 +119,15 @@ export default function PostTemplateEdit( {
119
119
  _fields: [ 'id' ],
120
120
  slug: templateSlug.replace( 'category-', '' ),
121
121
  } );
122
+ const templateTag =
123
+ inherit &&
124
+ templateSlug?.startsWith( 'tag-' ) &&
125
+ getEntityRecords( 'taxonomy', 'post_tag', {
126
+ context: 'view',
127
+ per_page: 1,
128
+ _fields: [ 'id' ],
129
+ slug: templateSlug.replace( 'tag-', '' ),
130
+ } );
122
131
  const query = {
123
132
  offset: offset || 0,
124
133
  order,
@@ -182,6 +191,16 @@ export default function PostTemplateEdit( {
182
191
  postType = query.postType;
183
192
  } else if ( templateCategory ) {
184
193
  query.categories = templateCategory[ 0 ]?.id;
194
+ } else if ( templateTag ) {
195
+ query.tags = templateTag[ 0 ]?.id;
196
+ } else if (
197
+ templateSlug?.startsWith( 'taxonomy-post_format' )
198
+ ) {
199
+ // Get the post format slug from the template slug by removing the prefix.
200
+ query.format = templateSlug.replace(
201
+ 'taxonomy-post_format-post-format-',
202
+ ''
203
+ );
185
204
  }
186
205
  }
187
206
  // When we preview Query Loop blocks we should prefer the current
@@ -71,8 +71,8 @@ function PostTimeToReadEdit( { attributes, setAttributes, context } ) {
71
71
  );
72
72
 
73
73
  return sprintf(
74
- /* translators: %d is the number of minutes the post will take to read. */
75
- _n( '%d minute', '%d minutes', minutesToRead ),
74
+ /* translators: %s: the number of minutes to read the post. */
75
+ _n( '%s minute', '%s minutes', minutesToRead ),
76
76
  minutesToRead
77
77
  );
78
78
  }, [ contentStructure, blocks ] );
@@ -32,7 +32,7 @@ function render_block_core_post_time_to_read( $attributes, $content, $block ) {
32
32
  $minutes_to_read = max( 1, (int) round( wp_word_count( $content, $word_count_type ) / $average_reading_rate ) );
33
33
 
34
34
  $minutes_to_read_string = sprintf(
35
- /* translators: %s is the number of minutes the post will take to read. */
35
+ /* translators: %s: the number of minutes to read the post. */
36
36
  _n( '%s minute', '%s minutes', $minutes_to_read ),
37
37
  $minutes_to_read
38
38
  );
@@ -42,7 +42,7 @@
42
42
  "default": false
43
43
  }
44
44
  },
45
- "usesContext": [ "postType" ],
45
+ "usesContext": [ "templateSlug" ],
46
46
  "providesContext": {
47
47
  "queryId": "queryId",
48
48
  "query": "query",