@wordpress/block-library 9.27.1-next.46f643fa0.0 → 9.28.1-next.0f6f9d12c.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 (271) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/build/accordion-header/edit.js +118 -0
  3. package/build/accordion-header/edit.js.map +1 -0
  4. package/build/accordion-header/index.js +124 -0
  5. package/build/accordion-header/index.js.map +1 -0
  6. package/build/accordion-header/init.js +12 -0
  7. package/build/accordion-header/init.js.map +1 -0
  8. package/build/accordion-header/save.js +81 -0
  9. package/build/accordion-header/save.js.map +1 -0
  10. package/build/accordion-item/edit.js +129 -0
  11. package/build/accordion-item/edit.js.map +1 -0
  12. package/build/accordion-item/icons.js +30 -0
  13. package/build/accordion-item/icons.js.map +1 -0
  14. package/build/accordion-item/index.js +79 -0
  15. package/build/accordion-item/index.js.map +1 -0
  16. package/build/accordion-item/init.js +12 -0
  17. package/build/accordion-item/init.js.map +1 -0
  18. package/build/accordion-item/save.js +37 -0
  19. package/build/accordion-item/save.js.map +1 -0
  20. package/build/accordion-panel/edit.js +59 -0
  21. package/build/accordion-panel/edit.js.map +1 -0
  22. package/build/accordion-panel/index.js +108 -0
  23. package/build/accordion-panel/index.js.map +1 -0
  24. package/build/accordion-panel/init.js +12 -0
  25. package/build/accordion-panel/init.js.map +1 -0
  26. package/build/accordion-panel/save.js +46 -0
  27. package/build/accordion-panel/save.js.map +1 -0
  28. package/build/accordions/edit.js +123 -0
  29. package/build/accordions/edit.js.map +1 -0
  30. package/build/accordions/index.js +103 -0
  31. package/build/accordions/index.js.map +1 -0
  32. package/build/accordions/init.js +12 -0
  33. package/build/accordions/init.js.map +1 -0
  34. package/build/accordions/save.js +36 -0
  35. package/build/accordions/save.js.map +1 -0
  36. package/build/accordions/view.js +49 -0
  37. package/build/accordions/view.js.map +1 -0
  38. package/build/cover/edit/index.js +1 -1
  39. package/build/cover/edit/index.js.map +1 -1
  40. package/build/cover/edit/inspector-controls.js +1 -1
  41. package/build/cover/edit/inspector-controls.js.map +1 -1
  42. package/build/cover/index.js +2 -1
  43. package/build/cover/index.js.map +1 -1
  44. package/build/file/edit.js +4 -2
  45. package/build/file/edit.js.map +1 -1
  46. package/build/file/edit.native.js +1 -1
  47. package/build/file/edit.native.js.map +1 -1
  48. package/build/file/transforms.js +6 -6
  49. package/build/file/transforms.js.map +1 -1
  50. package/build/file/utils/index.js +5 -0
  51. package/build/file/utils/index.js.map +1 -1
  52. package/build/freeform/edit.js +6 -0
  53. package/build/freeform/edit.js.map +1 -1
  54. package/build/gallery/use-get-media.js +3 -3
  55. package/build/gallery/use-get-media.js.map +1 -1
  56. package/build/gallery/use-get-media.native.js +3 -3
  57. package/build/gallery/use-get-media.native.js.map +1 -1
  58. package/build/image/edit.native.js +2 -2
  59. package/build/image/edit.native.js.map +1 -1
  60. package/build/image/image.js +1 -1
  61. package/build/image/image.js.map +1 -1
  62. package/build/index.js +10 -0
  63. package/build/index.js.map +1 -1
  64. package/build/list-item/edit.js +3 -0
  65. package/build/list-item/edit.js.map +1 -1
  66. package/build/media-text/edit.js +2 -2
  67. package/build/media-text/edit.js.map +1 -1
  68. package/build/media-text/media-container.js +2 -1
  69. package/build/media-text/media-container.js.map +1 -1
  70. package/build/media-text/transforms.js +7 -3
  71. package/build/media-text/transforms.js.map +1 -1
  72. package/build/more/edit.js +13 -28
  73. package/build/more/edit.js.map +1 -1
  74. package/build/post-comments-count/index.js +3 -0
  75. package/build/post-comments-count/index.js.map +1 -1
  76. package/build/post-comments-link/index.js +3 -0
  77. package/build/post-comments-link/index.js.map +1 -1
  78. package/build/post-featured-image/edit.js +2 -2
  79. package/build/post-featured-image/edit.js.map +1 -1
  80. package/build/query-title/edit.js +52 -2
  81. package/build/query-title/edit.js.map +1 -1
  82. package/build/query-title/index.js +1 -0
  83. package/build/query-title/index.js.map +1 -1
  84. package/build/query-title/use-post-type-label.js +42 -0
  85. package/build/query-title/use-post-type-label.js.map +1 -0
  86. package/build/query-title/variations.js +10 -0
  87. package/build/query-title/variations.js.map +1 -1
  88. package/build/site-logo/edit.js +58 -43
  89. package/build/site-logo/edit.js.map +1 -1
  90. package/build/site-title/edit.js +9 -3
  91. package/build/site-title/edit.js.map +1 -1
  92. package/build/social-link/icons/tiktok.js +2 -2
  93. package/build/social-link/icons/tiktok.js.map +1 -1
  94. package/build/utils/poster-image.js +54 -6
  95. package/build/utils/poster-image.js.map +1 -1
  96. package/build-module/accordion-header/edit.js +108 -0
  97. package/build-module/accordion-header/edit.js.map +1 -0
  98. package/build-module/accordion-header/index.js +116 -0
  99. package/build-module/accordion-header/index.js.map +1 -0
  100. package/build-module/accordion-header/init.js +6 -0
  101. package/build-module/accordion-header/init.js.map +1 -0
  102. package/build-module/accordion-header/save.js +71 -0
  103. package/build-module/accordion-header/save.js.map +1 -0
  104. package/build-module/accordion-item/edit.js +120 -0
  105. package/build-module/accordion-item/edit.js.map +1 -0
  106. package/build-module/accordion-item/icons.js +22 -0
  107. package/build-module/accordion-item/icons.js.map +1 -0
  108. package/build-module/accordion-item/index.js +71 -0
  109. package/build-module/accordion-item/index.js.map +1 -0
  110. package/build-module/accordion-item/init.js +6 -0
  111. package/build-module/accordion-item/init.js.map +1 -0
  112. package/build-module/accordion-item/save.js +28 -0
  113. package/build-module/accordion-item/save.js.map +1 -0
  114. package/build-module/accordion-panel/edit.js +50 -0
  115. package/build-module/accordion-panel/edit.js.map +1 -0
  116. package/build-module/accordion-panel/index.js +100 -0
  117. package/build-module/accordion-panel/index.js.map +1 -0
  118. package/build-module/accordion-panel/init.js +6 -0
  119. package/build-module/accordion-panel/init.js.map +1 -0
  120. package/build-module/accordion-panel/save.js +37 -0
  121. package/build-module/accordion-panel/save.js.map +1 -0
  122. package/build-module/accordions/edit.js +116 -0
  123. package/build-module/accordions/edit.js.map +1 -0
  124. package/build-module/accordions/index.js +95 -0
  125. package/build-module/accordions/index.js.map +1 -0
  126. package/build-module/accordions/init.js +6 -0
  127. package/build-module/accordions/init.js.map +1 -0
  128. package/build-module/accordions/save.js +27 -0
  129. package/build-module/accordions/save.js.map +1 -0
  130. package/build-module/accordions/view.js +46 -0
  131. package/build-module/accordions/view.js.map +1 -0
  132. package/build-module/cover/edit/index.js +1 -1
  133. package/build-module/cover/edit/index.js.map +1 -1
  134. package/build-module/cover/edit/inspector-controls.js +1 -1
  135. package/build-module/cover/edit/inspector-controls.js.map +1 -1
  136. package/build-module/cover/index.js +2 -1
  137. package/build-module/cover/index.js.map +1 -1
  138. package/build-module/file/edit.js +4 -2
  139. package/build-module/file/edit.js.map +1 -1
  140. package/build-module/file/edit.native.js +1 -1
  141. package/build-module/file/edit.native.js.map +1 -1
  142. package/build-module/file/transforms.js +6 -6
  143. package/build-module/file/transforms.js.map +1 -1
  144. package/build-module/file/utils/index.js +5 -0
  145. package/build-module/file/utils/index.js.map +1 -1
  146. package/build-module/freeform/edit.js +6 -0
  147. package/build-module/freeform/edit.js.map +1 -1
  148. package/build-module/gallery/use-get-media.js +3 -3
  149. package/build-module/gallery/use-get-media.js.map +1 -1
  150. package/build-module/gallery/use-get-media.native.js +3 -3
  151. package/build-module/gallery/use-get-media.native.js.map +1 -1
  152. package/build-module/image/edit.native.js +2 -2
  153. package/build-module/image/edit.native.js.map +1 -1
  154. package/build-module/image/image.js +1 -1
  155. package/build-module/image/image.js.map +1 -1
  156. package/build-module/index.js +10 -0
  157. package/build-module/index.js.map +1 -1
  158. package/build-module/list-item/edit.js +3 -0
  159. package/build-module/list-item/edit.js.map +1 -1
  160. package/build-module/media-text/edit.js +2 -2
  161. package/build-module/media-text/edit.js.map +1 -1
  162. package/build-module/media-text/media-container.js +2 -1
  163. package/build-module/media-text/media-container.js.map +1 -1
  164. package/build-module/media-text/transforms.js +7 -3
  165. package/build-module/media-text/transforms.js.map +1 -1
  166. package/build-module/more/edit.js +15 -29
  167. package/build-module/more/edit.js.map +1 -1
  168. package/build-module/post-comments-count/index.js +3 -0
  169. package/build-module/post-comments-count/index.js.map +1 -1
  170. package/build-module/post-comments-link/index.js +3 -0
  171. package/build-module/post-comments-link/index.js.map +1 -1
  172. package/build-module/post-featured-image/edit.js +2 -2
  173. package/build-module/post-featured-image/edit.js.map +1 -1
  174. package/build-module/query-title/edit.js +52 -2
  175. package/build-module/query-title/edit.js.map +1 -1
  176. package/build-module/query-title/index.js +1 -0
  177. package/build-module/query-title/index.js.map +1 -1
  178. package/build-module/query-title/use-post-type-label.js +36 -0
  179. package/build-module/query-title/use-post-type-label.js.map +1 -0
  180. package/build-module/query-title/variations.js +10 -0
  181. package/build-module/query-title/variations.js.map +1 -1
  182. package/build-module/site-logo/edit.js +59 -44
  183. package/build-module/site-logo/edit.js.map +1 -1
  184. package/build-module/site-title/edit.js +10 -4
  185. package/build-module/site-title/edit.js.map +1 -1
  186. package/build-module/social-link/icons/tiktok.js +2 -2
  187. package/build-module/social-link/icons/tiktok.js.map +1 -1
  188. package/build-module/utils/poster-image.js +57 -9
  189. package/build-module/utils/poster-image.js.map +1 -1
  190. package/build-style/accordions/style-rtl.css +223 -0
  191. package/build-style/accordions/style.css +223 -0
  192. package/build-style/editor-rtl.css +23 -26
  193. package/build-style/editor.css +23 -26
  194. package/build-style/gallery/style-rtl.css +1 -2
  195. package/build-style/gallery/style.css +1 -2
  196. package/build-style/image/style-rtl.css +1 -2
  197. package/build-style/image/style.css +1 -2
  198. package/build-style/more/editor-rtl.css +3 -11
  199. package/build-style/more/editor.css +3 -11
  200. package/build-style/post-featured-image/editor-rtl.css +1 -2
  201. package/build-style/post-featured-image/editor.css +1 -2
  202. package/build-style/style-rtl.css +90 -4
  203. package/build-style/style.css +90 -4
  204. package/package.json +36 -35
  205. package/src/accordion-header/block.json +93 -0
  206. package/src/accordion-header/edit.js +128 -0
  207. package/src/accordion-header/index.js +24 -0
  208. package/src/accordion-header/init.js +6 -0
  209. package/src/accordion-header/save.js +79 -0
  210. package/src/accordion-item/block.json +45 -0
  211. package/src/accordion-item/edit.js +149 -0
  212. package/src/accordion-item/icons.js +23 -0
  213. package/src/accordion-item/index.js +24 -0
  214. package/src/accordion-item/index.php +73 -0
  215. package/src/accordion-item/init.js +6 -0
  216. package/src/accordion-item/save.js +25 -0
  217. package/src/accordion-panel/block.json +74 -0
  218. package/src/accordion-panel/edit.js +61 -0
  219. package/src/accordion-panel/index.js +24 -0
  220. package/src/accordion-panel/init.js +6 -0
  221. package/src/accordion-panel/save.js +51 -0
  222. package/src/accordions/block.json +69 -0
  223. package/src/accordions/edit.js +133 -0
  224. package/src/accordions/index.js +24 -0
  225. package/src/accordions/index.php +61 -0
  226. package/src/accordions/init.js +6 -0
  227. package/src/accordions/save.js +23 -0
  228. package/src/accordions/style.scss +91 -0
  229. package/src/accordions/view.js +38 -0
  230. package/src/block/index.php +35 -20
  231. package/src/cover/block.json +2 -1
  232. package/src/cover/edit/index.js +8 -3
  233. package/src/cover/edit/inspector-controls.js +6 -1
  234. package/src/file/edit.js +9 -4
  235. package/src/file/edit.native.js +5 -1
  236. package/src/file/index.php +28 -22
  237. package/src/file/transforms.js +6 -6
  238. package/src/file/utils/index.js +5 -0
  239. package/src/form-input/index.php +4 -2
  240. package/src/freeform/edit.js +7 -0
  241. package/src/gallery/use-get-media.js +9 -5
  242. package/src/gallery/use-get-media.native.js +10 -6
  243. package/src/image/edit.native.js +4 -2
  244. package/src/image/image.js +6 -1
  245. package/src/image/index.php +1 -1
  246. package/src/image/test/edit.native.js +16 -10
  247. package/src/index.js +12 -0
  248. package/src/list-item/edit.js +3 -0
  249. package/src/loginout/index.php +4 -2
  250. package/src/media-text/edit.js +16 -6
  251. package/src/media-text/media-container.js +1 -0
  252. package/src/media-text/transforms.js +5 -1
  253. package/src/more/edit.js +27 -33
  254. package/src/more/editor.scss +3 -12
  255. package/src/post-comments-count/block.json +3 -0
  256. package/src/post-comments-link/block.json +3 -0
  257. package/src/post-date/index.php +28 -32
  258. package/src/post-excerpt/index.php +16 -12
  259. package/src/post-featured-image/edit.js +2 -2
  260. package/src/query-title/block.json +1 -0
  261. package/src/query-title/edit.js +58 -1
  262. package/src/query-title/index.php +30 -5
  263. package/src/query-title/use-post-type-label.js +34 -0
  264. package/src/query-title/variations.js +13 -0
  265. package/src/site-logo/edit.js +44 -16
  266. package/src/site-title/edit.js +24 -16
  267. package/src/social-link/icons/tiktok.js +2 -2
  268. package/src/social-link/index.php +1 -1
  269. package/src/style.scss +1 -0
  270. package/src/utils/poster-image.js +62 -17
  271. package/src/utils/poster-image.scss +23 -16
@@ -20,18 +20,6 @@ function render_block_core_post_excerpt( $attributes, $content, $block ) {
20
20
  return '';
21
21
  }
22
22
 
23
- /*
24
- * The purpose of the excerpt length setting is to limit the length of both
25
- * automatically generated and user-created excerpts.
26
- * Because the excerpt_length filter only applies to auto generated excerpts,
27
- * wp_trim_words is used instead.
28
- */
29
- $excerpt_length = $attributes['excerptLength'];
30
- $excerpt = get_the_excerpt( $block->context['postId'] );
31
- if ( isset( $excerpt_length ) ) {
32
- $excerpt = wp_trim_words( $excerpt, $excerpt_length );
33
- }
34
-
35
23
  $more_text = ! empty( $attributes['moreText'] ) ? '<a class="wp-block-post-excerpt__more-link" href="' . esc_url( get_the_permalink( $block->context['postId'] ) ) . '">' . wp_kses_post( $attributes['moreText'] ) . '</a>' : '';
36
24
  $filter_excerpt_more = static function ( $more ) use ( $more_text ) {
37
25
  return empty( $more_text ) ? $more : '';
@@ -44,8 +32,24 @@ function render_block_core_post_excerpt( $attributes, $content, $block ) {
44
32
  * So if the block's attribute is not empty override the
45
33
  * `excerpt_more` filter and return nothing. This will
46
34
  * result in showing only one `read more` link at a time.
35
+ *
36
+ * This hook needs to be applied before the excerpt is retrieved with get_the_excerpt.
37
+ * Otherwise, the read more link filter from the theme is not removed.
47
38
  */
48
39
  add_filter( 'excerpt_more', $filter_excerpt_more );
40
+
41
+ /*
42
+ * The purpose of the excerpt length setting is to limit the length of both
43
+ * automatically generated and user-created excerpts.
44
+ * Because the excerpt_length filter only applies to auto generated excerpts,
45
+ * wp_trim_words is used instead.
46
+ */
47
+ $excerpt_length = $attributes['excerptLength'];
48
+ $excerpt = get_the_excerpt( $block->context['postId'] );
49
+ if ( isset( $excerpt_length ) ) {
50
+ $excerpt = wp_trim_words( $excerpt, $excerpt_length );
51
+ }
52
+
49
53
  $classes = array();
50
54
  if ( isset( $attributes['textAlign'] ) ) {
51
55
  $classes[] = 'has-text-align-' . $attributes['textAlign'];
@@ -133,12 +133,12 @@ export default function PostFeaturedImageEdit( {
133
133
 
134
134
  const { media, postType, postPermalink } = useSelect(
135
135
  ( select ) => {
136
- const { getMedia, getPostType, getEditedEntityRecord } =
136
+ const { getEntityRecord, getPostType, getEditedEntityRecord } =
137
137
  select( coreStore );
138
138
  return {
139
139
  media:
140
140
  featuredImage &&
141
- getMedia( featuredImage, {
141
+ getEntityRecord( 'postType', 'attachment', featuredImage, {
142
142
  context: 'view',
143
143
  } ),
144
144
  postType: postTypeSlug && getPostType( postTypeSlug ),
@@ -34,6 +34,7 @@
34
34
  "type": "search"
35
35
  }
36
36
  },
37
+ "usesContext": [ "query" ],
37
38
  "supports": {
38
39
  "align": [ "wide", "full" ],
39
40
  "html": false,
@@ -25,9 +25,10 @@ import { __, _x, sprintf } from '@wordpress/i18n';
25
25
  * Internal dependencies
26
26
  */
27
27
  import { useArchiveLabel } from './use-archive-label';
28
+ import { usePostTypeLabel } from './use-post-type-label';
28
29
  import { useToolsPanelDropdownMenuProps } from '../utils/hooks';
29
30
 
30
- const SUPPORTED_TYPES = [ 'archive', 'search' ];
31
+ const SUPPORTED_TYPES = [ 'archive', 'search', 'post-type' ];
31
32
 
32
33
  export default function QueryTitleEdit( {
33
34
  attributes: {
@@ -39,8 +40,10 @@ export default function QueryTitleEdit( {
39
40
  showSearchTerm,
40
41
  },
41
42
  setAttributes,
43
+ context: { query },
42
44
  } ) {
43
45
  const { archiveTypeLabel, archiveNameLabel } = useArchiveLabel();
46
+ const { postTypeLabel } = usePostTypeLabel( query?.postType );
44
47
  const dropdownMenuProps = useToolsPanelDropdownMenuProps();
45
48
 
46
49
  const TagName = `h${ level }`;
@@ -174,6 +177,60 @@ export default function QueryTitleEdit( {
174
177
  );
175
178
  }
176
179
 
180
+ if ( type === 'post-type' ) {
181
+ let title;
182
+ if ( postTypeLabel ) {
183
+ if ( showPrefix ) {
184
+ title = sprintf(
185
+ /* translators: %s: Singular post type name of the queried object */
186
+ __( 'Post Type: "%s"' ),
187
+ postTypeLabel
188
+ );
189
+ } else {
190
+ title = postTypeLabel;
191
+ }
192
+ } else {
193
+ title = showPrefix ? __( 'Post Type: Name' ) : __( 'Name' );
194
+ }
195
+
196
+ titleElement = (
197
+ <>
198
+ <InspectorControls>
199
+ <ToolsPanel
200
+ label={ __( 'Settings' ) }
201
+ resetAll={ () =>
202
+ setAttributes( {
203
+ showPrefix: true,
204
+ } )
205
+ }
206
+ dropdownMenuProps={ dropdownMenuProps }
207
+ >
208
+ <ToolsPanelItem
209
+ hasValue={ () => ! showPrefix }
210
+ label={ __( 'Show post type label' ) }
211
+ onDeselect={ () =>
212
+ setAttributes( { showPrefix: true } )
213
+ }
214
+ isShownByDefault
215
+ >
216
+ <ToggleControl
217
+ __nextHasNoMarginBottom
218
+ label={ __( 'Show post type label' ) }
219
+ onChange={ () =>
220
+ setAttributes( {
221
+ showPrefix: ! showPrefix,
222
+ } )
223
+ }
224
+ checked={ showPrefix }
225
+ />
226
+ </ToolsPanelItem>
227
+ </ToolsPanel>
228
+ </InspectorControls>
229
+ <TagName { ...blockProps }>{ title }</TagName>
230
+ </>
231
+ );
232
+ }
233
+
177
234
  return (
178
235
  <>
179
236
  <BlockControls group="block">
@@ -7,23 +7,28 @@
7
7
 
8
8
  /**
9
9
  * Renders the `core/query-title` block on the server.
10
- * For now it only supports Archive title,
10
+ * For now it supports Archive title, Search title, and Post Type Label,
11
11
  * using queried object information
12
12
  *
13
13
  * @since 5.8.0
14
14
  *
15
- * @param array $attributes Block attributes.
15
+ * @param array $attributes Block attributes.
16
+ * @param array $_content Block content.
17
+ * @param object $block Block instance.
16
18
  *
17
19
  * @return string Returns the query title based on the queried object.
18
20
  */
19
- function render_block_core_query_title( $attributes ) {
21
+ function render_block_core_query_title( $attributes, $content, $block ) {
20
22
  $type = isset( $attributes['type'] ) ? $attributes['type'] : null;
21
23
  $is_archive = is_archive();
22
24
  $is_search = is_search();
25
+ $post_type = isset( $block->context['query']['postType'] ) ? $block->context['query']['postType'] : get_post_type();
26
+
23
27
  if ( ! $type ||
24
28
  ( 'archive' === $type && ! $is_archive ) ||
25
- ( 'search' === $type && ! $is_search )
26
- ) {
29
+ ( 'search' === $type && ! $is_search ) ||
30
+ ( 'post-type' === $type && ! $post_type )
31
+ ) {
27
32
  return '';
28
33
  }
29
34
  $title = '';
@@ -48,6 +53,26 @@ function render_block_core_query_title( $attributes ) {
48
53
  );
49
54
  }
50
55
  }
56
+ if ( 'post-type' === $type ) {
57
+ $post_type_object = get_post_type_object( $post_type );
58
+
59
+ if ( ! $post_type_object ) {
60
+ return '';
61
+ }
62
+
63
+ $post_type_name = $post_type_object->labels->singular_name;
64
+ $show_prefix = isset( $attributes['showPrefix'] ) ? $attributes['showPrefix'] : true;
65
+
66
+ if ( $show_prefix ) {
67
+ $title = sprintf(
68
+ /* translators: %s is the post type name. */
69
+ __( 'Post Type: "%s"' ),
70
+ $post_type_name
71
+ );
72
+ } else {
73
+ $title = $post_type_name;
74
+ }
75
+ }
51
76
 
52
77
  $tag_name = isset( $attributes['level'] ) ? 'h' . (int) $attributes['level'] : 'h1';
53
78
  $align_class_name = empty( $attributes['textAlign'] ) ? '' : "has-text-align-{$attributes['textAlign']}";
@@ -0,0 +1,34 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import { store as coreStore } from '@wordpress/core-data';
5
+ import { useSelect } from '@wordpress/data';
6
+
7
+ /**
8
+ * Hook to fetch the singular label for the current post type.
9
+ *
10
+ * @param {string} contextPostType Context provided post type.
11
+ */
12
+ export function usePostTypeLabel( contextPostType ) {
13
+ const currentPostType = useSelect( ( select ) => {
14
+ // Access core/editor by string to avoid @wordpress/editor dependency.
15
+ // eslint-disable-next-line @wordpress/data-no-store-string-literals
16
+ const { getCurrentPostType } = select( 'core/editor' );
17
+ return getCurrentPostType();
18
+ }, [] );
19
+
20
+ // Fetch the post type label from the core data store
21
+ return useSelect(
22
+ ( select ) => {
23
+ const { getPostType } = select( coreStore );
24
+ const postTypeSlug = contextPostType || currentPostType;
25
+ const postType = getPostType( postTypeSlug );
26
+
27
+ // Return the singular name of the post type
28
+ return {
29
+ postTypeLabel: postType ? postType.labels.singular_name : '',
30
+ };
31
+ },
32
+ [ contextPostType, currentPostType ]
33
+ );
34
+ }
@@ -30,6 +30,19 @@ const variations = [
30
30
  },
31
31
  scope: [ 'inserter' ],
32
32
  },
33
+ {
34
+ isDefault: false,
35
+ name: 'post-type-label',
36
+ title: __( 'Post Type Label' ),
37
+ description: __(
38
+ 'Display the post type label based on the queried object.'
39
+ ),
40
+ icon: title,
41
+ attributes: {
42
+ type: 'post-type',
43
+ },
44
+ scope: [ 'inserter' ],
45
+ },
33
46
  ];
34
47
 
35
48
  /**
@@ -38,6 +38,7 @@ import {
38
38
  useBlockProps,
39
39
  store as blockEditorStore,
40
40
  __experimentalImageEditor as ImageEditor,
41
+ useBlockEditingMode,
41
42
  } from '@wordpress/block-editor';
42
43
  import { useSelect, useDispatch } from '@wordpress/data';
43
44
  import { store as coreStore } from '@wordpress/core-data';
@@ -73,6 +74,16 @@ const SiteLogo = ( {
73
74
  const [ isEditingImage, setIsEditingImage ] = useState( false );
74
75
  const { toggleSelection } = useDispatch( blockEditorStore );
75
76
  const dropdownMenuProps = useToolsPanelDropdownMenuProps();
77
+
78
+ // Check if we're in contentOnly mode
79
+ const blockEditingMode = useBlockEditingMode();
80
+ const isNavigationMode = useSelect(
81
+ ( select ) => select( blockEditorStore ).isNavigationMode(),
82
+ []
83
+ );
84
+ const isContentOnlyMode = blockEditingMode === 'contentOnly';
85
+ const isContentOnlyWriteMode = isNavigationMode && isContentOnlyMode;
86
+
76
87
  const { imageEditing, maxWidth, title } = useSelect( ( select ) => {
77
88
  const settings = select( blockEditorStore ).getSettings();
78
89
  const siteEntities = select( coreStore ).getEntityRecord(
@@ -205,8 +216,12 @@ const SiteLogo = ( {
205
216
  const canEditImage =
206
217
  logoId && naturalWidth && naturalHeight && imageEditing;
207
218
 
208
- const imgEdit =
209
- canEditImage && isEditingImage ? (
219
+ // Hide crop and dimensions editing in write mode
220
+ const shouldShowCropAndDimensions = ! isContentOnlyWriteMode;
221
+
222
+ let imgEdit;
223
+ if ( canEditImage && isEditingImage ) {
224
+ imgEdit = (
210
225
  <ImageEditor
211
226
  id={ logoId }
212
227
  url={ logoUrl }
@@ -221,13 +236,16 @@ const SiteLogo = ( {
221
236
  setIsEditingImage( false );
222
237
  } }
223
238
  />
224
- ) : (
239
+ );
240
+ } else {
241
+ // Always render ResizableBox but disable resize functionality in contentOnly mode
242
+ imgEdit = (
225
243
  <ResizableBox
226
244
  size={ {
227
245
  width: currentWidth,
228
246
  height: currentHeight,
229
247
  } }
230
- showHandle={ isSelected }
248
+ showHandle={ isSelected && shouldShowCropAndDimensions }
231
249
  minWidth={ minWidth }
232
250
  maxWidth={ maxWidthBuffer }
233
251
  minHeight={ minHeight }
@@ -251,6 +269,7 @@ const SiteLogo = ( {
251
269
  { imgWrapper }
252
270
  </ResizableBox>
253
271
  );
272
+ }
254
273
 
255
274
  // Support the previous location for the Site Icon settings. To be removed
256
275
  // when the required WP core version for Gutenberg is >= 6.5.0.
@@ -371,15 +390,17 @@ const SiteLogo = ( {
371
390
  ) }
372
391
  </ToolsPanel>
373
392
  </InspectorControls>
374
- <BlockControls group="block">
375
- { canEditImage && ! isEditingImage && (
376
- <ToolbarButton
377
- onClick={ () => setIsEditingImage( true ) }
378
- icon={ crop }
379
- label={ __( 'Crop' ) }
380
- />
393
+ { canEditImage &&
394
+ ! isEditingImage &&
395
+ shouldShowCropAndDimensions && (
396
+ <BlockControls group="block">
397
+ <ToolbarButton
398
+ onClick={ () => setIsEditingImage( true ) }
399
+ icon={ crop }
400
+ label={ __( 'Crop' ) }
401
+ />
402
+ </BlockControls>
381
403
  ) }
382
- </BlockControls>
383
404
  { imgEdit }
384
405
  </>
385
406
  );
@@ -454,12 +475,19 @@ export default function LogoEdit( {
454
475
  const _siteIconId = siteSettings?.site_icon;
455
476
  const mediaItem =
456
477
  _siteLogoId &&
457
- select( coreStore ).getMedia( _siteLogoId, {
458
- context: 'view',
459
- } );
478
+ select( coreStore ).getEntityRecord(
479
+ 'postType',
480
+ 'attachment',
481
+ _siteLogoId,
482
+ {
483
+ context: 'view',
484
+ }
485
+ );
460
486
  const _isRequestingMediaItem =
461
487
  !! _siteLogoId &&
462
- ! select( coreStore ).hasFinishedResolution( 'getMedia', [
488
+ ! select( coreStore ).hasFinishedResolution( 'getEntityRecord', [
489
+ 'postType',
490
+ 'attachment',
463
491
  _siteLogoId,
464
492
  { context: 'view' },
465
493
  ] );
@@ -16,6 +16,8 @@ import {
16
16
  BlockControls,
17
17
  useBlockProps,
18
18
  HeadingLevelDropdown,
19
+ useBlockEditingMode,
20
+ store as blockEditorStore,
19
21
  } from '@wordpress/block-editor';
20
22
  import {
21
23
  ToggleControl,
@@ -36,9 +38,11 @@ export default function SiteTitleEdit( {
36
38
  insertBlocksAfter,
37
39
  } ) {
38
40
  const { level, levelOptions, textAlign, isLink, linkTarget } = attributes;
39
- const { canUserEdit, title } = useSelect( ( select ) => {
41
+ const { canUserEdit, title, isNavigationMode } = useSelect( ( select ) => {
40
42
  const { canUser, getEntityRecord, getEditedEntityRecord } =
41
43
  select( coreStore );
44
+ const { isNavigationMode: _isNavigationMode } =
45
+ select( blockEditorStore );
42
46
  const canEdit = canUser( 'update', {
43
47
  kind: 'root',
44
48
  name: 'site',
@@ -49,10 +53,12 @@ export default function SiteTitleEdit( {
49
53
  return {
50
54
  canUserEdit: canEdit,
51
55
  title: canEdit ? settings?.title : readOnlySettings?.name,
56
+ isNavigationMode: _isNavigationMode(),
52
57
  };
53
58
  }, [] );
54
59
  const { editEntityRecord } = useDispatch( coreStore );
55
60
  const dropdownMenuProps = useToolsPanelDropdownMenuProps();
61
+ const blockEditingMode = useBlockEditingMode();
56
62
 
57
63
  function setTitle( newTitle ) {
58
64
  editEntityRecord( 'root', 'site', undefined, {
@@ -103,21 +109,23 @@ export default function SiteTitleEdit( {
103
109
  );
104
110
  return (
105
111
  <>
106
- <BlockControls group="block">
107
- <HeadingLevelDropdown
108
- value={ level }
109
- options={ levelOptions }
110
- onChange={ ( newLevel ) =>
111
- setAttributes( { level: newLevel } )
112
- }
113
- />
114
- <AlignmentControl
115
- value={ textAlign }
116
- onChange={ ( nextAlign ) => {
117
- setAttributes( { textAlign: nextAlign } );
118
- } }
119
- />
120
- </BlockControls>
112
+ { ! isNavigationMode && blockEditingMode === 'default' && (
113
+ <BlockControls group="block">
114
+ <HeadingLevelDropdown
115
+ value={ level }
116
+ options={ levelOptions }
117
+ onChange={ ( newLevel ) =>
118
+ setAttributes( { level: newLevel } )
119
+ }
120
+ />
121
+ <AlignmentControl
122
+ value={ textAlign }
123
+ onChange={ ( nextAlign ) => {
124
+ setAttributes( { textAlign: nextAlign } );
125
+ } }
126
+ />
127
+ </BlockControls>
128
+ ) }
121
129
  <InspectorControls>
122
130
  <ToolsPanel
123
131
  label={ __( 'Settings' ) }
@@ -4,7 +4,7 @@
4
4
  import { Path, SVG } from '@wordpress/primitives';
5
5
 
6
6
  export const TiktokIcon = () => (
7
- <SVG width="24" height="24" viewBox="0 0 32 32" version="1.1">
8
- <Path d="M16.708 0.027c1.745-0.027 3.48-0.011 5.213-0.027 0.105 2.041 0.839 4.12 2.333 5.563 1.491 1.479 3.6 2.156 5.652 2.385v5.369c-1.923-0.063-3.855-0.463-5.6-1.291-0.76-0.344-1.468-0.787-2.161-1.24-0.009 3.896 0.016 7.787-0.025 11.667-0.104 1.864-0.719 3.719-1.803 5.255-1.744 2.557-4.771 4.224-7.88 4.276-1.907 0.109-3.812-0.411-5.437-1.369-2.693-1.588-4.588-4.495-4.864-7.615-0.032-0.667-0.043-1.333-0.016-1.984 0.24-2.537 1.495-4.964 3.443-6.615 2.208-1.923 5.301-2.839 8.197-2.297 0.027 1.975-0.052 3.948-0.052 5.923-1.323-0.428-2.869-0.308-4.025 0.495-0.844 0.547-1.485 1.385-1.819 2.333-0.276 0.676-0.197 1.427-0.181 2.145 0.317 2.188 2.421 4.027 4.667 3.828 1.489-0.016 2.916-0.88 3.692-2.145 0.251-0.443 0.532-0.896 0.547-1.417 0.131-2.385 0.079-4.76 0.095-7.145 0.011-5.375-0.016-10.735 0.025-16.093z" />
7
+ <SVG width="24" height="24" viewBox="0 0 24 24" version="1.1">
8
+ <Path d="M12.4044 3.01519C13.4086 3 14.4072 3.009 15.4045 3C15.465 4.14812 15.8874 5.31762 16.7472 6.12935C17.6053 6.96134 18.819 7.34217 20 7.47099V10.4912C18.8933 10.4558 17.7814 10.2308 16.7771 9.76499C16.3397 9.57148 15.9323 9.32227 15.5334 9.06745C15.5283 11.2591 15.5426 13.4479 15.5191 15.6305C15.4592 16.679 15.1053 17.7225 14.4814 18.5866C13.4777 20.025 11.7356 20.9627 9.94635 20.992C8.84885 21.0533 7.7525 20.7608 6.81729 20.2219C5.26743 19.3286 4.17683 17.6933 4.01799 15.9382C3.99957 15.563 3.99324 15.1883 4.00878 14.8221C4.14691 13.395 4.86917 12.0297 5.99027 11.101C7.26101 10.0192 9.04107 9.50397 10.7078 9.80886C10.7233 10.9199 10.6778 12.0297 10.6778 13.1407C9.91643 12.9 9.02668 12.9675 8.36139 13.4192C7.87566 13.7269 7.50675 14.1983 7.31453 14.7316C7.15569 15.1118 7.20116 15.5343 7.21036 15.9382C7.3928 17.169 8.60368 18.2035 9.89628 18.0916C10.7532 18.0826 11.5745 17.5965 12.0211 16.8849C12.1655 16.6357 12.3273 16.3809 12.3359 16.0878C12.4113 14.7462 12.3814 13.4102 12.3906 12.0685C12.3969 9.04495 12.3814 6.02979 12.4049 3.01575L12.4044 3.01519Z" />
9
9
  </SVG>
10
10
  );
@@ -274,7 +274,7 @@ function block_core_social_link_services( $service = '', $field = '' ) {
274
274
  'icon' => '<svg width="24" height="24" viewBox="0 0 24 24" version="1.1" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false"><path d="M12.065,2a5.526,5.526,0,0,1,3.132.892A5.854,5.854,0,0,1,17.326,5.4a5.821,5.821,0,0,1,.351,2.33q0,.612-.117,2.487a.809.809,0,0,0,.365.091,1.93,1.93,0,0,0,.664-.176,1.93,1.93,0,0,1,.664-.176,1.3,1.3,0,0,1,.729.234.7.7,0,0,1,.351.6.839.839,0,0,1-.41.7,2.732,2.732,0,0,1-.9.41,3.192,3.192,0,0,0-.9.378.728.728,0,0,0-.41.618,1.575,1.575,0,0,0,.156.56,6.9,6.9,0,0,0,1.334,1.953,5.6,5.6,0,0,0,1.881,1.315,5.875,5.875,0,0,0,1.042.3.42.42,0,0,1,.365.456q0,.911-2.852,1.341a1.379,1.379,0,0,0-.143.507,1.8,1.8,0,0,1-.182.605.451.451,0,0,1-.429.241,5.878,5.878,0,0,1-.807-.085,5.917,5.917,0,0,0-.833-.085,4.217,4.217,0,0,0-.807.065,2.42,2.42,0,0,0-.82.293,6.682,6.682,0,0,0-.755.5q-.351.267-.755.527a3.886,3.886,0,0,1-.989.436A4.471,4.471,0,0,1,11.831,22a4.307,4.307,0,0,1-1.256-.176,3.784,3.784,0,0,1-.976-.436q-.4-.26-.749-.527a6.682,6.682,0,0,0-.755-.5,2.422,2.422,0,0,0-.807-.293,4.432,4.432,0,0,0-.82-.065,5.089,5.089,0,0,0-.853.1,5,5,0,0,1-.762.1.474.474,0,0,1-.456-.241,1.819,1.819,0,0,1-.182-.618,1.411,1.411,0,0,0-.143-.521q-2.852-.429-2.852-1.341a.42.42,0,0,1,.365-.456,5.793,5.793,0,0,0,1.042-.3,5.524,5.524,0,0,0,1.881-1.315,6.789,6.789,0,0,0,1.334-1.953A1.575,1.575,0,0,0,6,12.9a.728.728,0,0,0-.41-.618,3.323,3.323,0,0,0-.9-.384,2.912,2.912,0,0,1-.9-.41.814.814,0,0,1-.41-.684.71.71,0,0,1,.338-.593,1.208,1.208,0,0,1,.716-.241,1.976,1.976,0,0,1,.625.169,2.008,2.008,0,0,0,.69.169.919.919,0,0,0,.416-.091q-.117-1.849-.117-2.474A5.861,5.861,0,0,1,6.385,5.4,5.516,5.516,0,0,1,8.625,2.819,7.075,7.075,0,0,1,12.062,2Z"></path></svg>',
275
275
  ),
276
276
  'soundcloud' => array(
277
- 'name' => _x( 'Soundcloud', 'social link block variation name' ),
277
+ 'name' => _x( 'SoundCloud', 'social link block variation name' ),
278
278
  'icon' => '<svg width="24" height="24" viewBox="0 0 24 24" version="1.1" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false"><path d="M8.9,16.1L9,14L8.9,9.5c0-0.1,0-0.1-0.1-0.1c0,0-0.1-0.1-0.1-0.1c-0.1,0-0.1,0-0.1,0.1c0,0-0.1,0.1-0.1,0.1L8.3,14l0.1,2.1 c0,0.1,0,0.1,0.1,0.1c0,0,0.1,0.1,0.1,0.1C8.8,16.3,8.9,16.3,8.9,16.1z M11.4,15.9l0.1-1.8L11.4,9c0-0.1,0-0.2-0.1-0.2 c0,0-0.1,0-0.1,0s-0.1,0-0.1,0c-0.1,0-0.1,0.1-0.1,0.2l0,0.1l-0.1,5c0,0,0,0.7,0.1,2v0c0,0.1,0,0.1,0.1,0.1c0.1,0.1,0.1,0.1,0.2,0.1 c0.1,0,0.1,0,0.2-0.1c0.1,0,0.1-0.1,0.1-0.2L11.4,15.9z M2.4,12.9L2.5,14l-0.2,1.1c0,0.1,0,0.1-0.1,0.1c0,0-0.1,0-0.1-0.1L2.1,14 l0.1-1.1C2.2,12.9,2.3,12.9,2.4,12.9C2.3,12.9,2.4,12.9,2.4,12.9z M3.1,12.2L3.3,14l-0.2,1.8c0,0.1,0,0.1-0.1,0.1 c-0.1,0-0.1,0-0.1-0.1L2.8,14L3,12.2C3,12.2,3,12.2,3.1,12.2C3.1,12.2,3.1,12.2,3.1,12.2z M3.9,11.9L4.1,14l-0.2,2.1 c0,0.1,0,0.1-0.1,0.1c-0.1,0-0.1,0-0.1-0.1L3.5,14l0.2-2.1c0-0.1,0-0.1,0.1-0.1C3.9,11.8,3.9,11.8,3.9,11.9z M4.7,11.9L4.9,14 l-0.2,2.1c0,0.1-0.1,0.1-0.1,0.1c-0.1,0-0.1,0-0.1-0.1L4.3,14l0.2-2.2c0-0.1,0-0.1,0.1-0.1C4.7,11.7,4.7,11.8,4.7,11.9z M5.6,12 l0.2,2l-0.2,2.1c0,0.1-0.1,0.1-0.1,0.1c0,0-0.1,0-0.1,0c0,0,0-0.1,0-0.1L5.1,14l0.2-2c0,0,0-0.1,0-0.1s0.1,0,0.1,0 C5.5,11.9,5.5,11.9,5.6,12L5.6,12z M6.4,10.7L6.6,14l-0.2,2.1c0,0,0,0.1,0,0.1c0,0-0.1,0-0.1,0c-0.1,0-0.1-0.1-0.2-0.2L5.9,14 l0.2-3.3c0-0.1,0.1-0.2,0.2-0.2c0,0,0.1,0,0.1,0C6.4,10.7,6.4,10.7,6.4,10.7z M7.2,10l0.2,4.1l-0.2,2.1c0,0,0,0.1,0,0.1 c0,0-0.1,0-0.1,0c-0.1,0-0.2-0.1-0.2-0.2l-0.1-2.1L6.8,10c0-0.1,0.1-0.2,0.2-0.2c0,0,0.1,0,0.1,0S7.2,9.9,7.2,10z M8,9.6L8.2,14 L8,16.1c0,0.1-0.1,0.2-0.2,0.2c-0.1,0-0.2-0.1-0.2-0.2L7.5,14l0.1-4.4c0-0.1,0-0.1,0.1-0.1c0,0,0.1-0.1,0.1-0.1c0.1,0,0.1,0,0.1,0.1 C8,9.6,8,9.6,8,9.6z M11.4,16.1L11.4,16.1L11.4,16.1z M9.7,9.6L9.8,14l-0.1,2.1c0,0.1,0,0.1-0.1,0.2s-0.1,0.1-0.2,0.1 c-0.1,0-0.1,0-0.1-0.1s-0.1-0.1-0.1-0.2L9.2,14l0.1-4.4c0-0.1,0-0.1,0.1-0.2s0.1-0.1,0.2-0.1c0.1,0,0.1,0,0.2,0.1S9.7,9.5,9.7,9.6 L9.7,9.6z M10.6,9.8l0.1,4.3l-0.1,2c0,0.1,0,0.1-0.1,0.2c0,0-0.1,0.1-0.2,0.1c-0.1,0-0.1,0-0.2-0.1c0,0-0.1-0.1-0.1-0.2L10,14 l0.1-4.3c0-0.1,0-0.1,0.1-0.2c0,0,0.1-0.1,0.2-0.1c0.1,0,0.1,0,0.2,0.1S10.6,9.7,10.6,9.8z M12.4,14l-0.1,2c0,0.1,0,0.1-0.1,0.2 c-0.1,0.1-0.1,0.1-0.2,0.1c-0.1,0-0.1,0-0.2-0.1c-0.1-0.1-0.1-0.1-0.1-0.2l-0.1-1l-0.1-1l0.1-5.5v0c0-0.1,0-0.2,0.1-0.2 c0.1,0,0.1-0.1,0.2-0.1c0,0,0.1,0,0.1,0c0.1,0,0.1,0.1,0.1,0.2L12.4,14z M22.1,13.9c0,0.7-0.2,1.3-0.7,1.7c-0.5,0.5-1.1,0.7-1.7,0.7 h-6.8c-0.1,0-0.1,0-0.2-0.1c-0.1-0.1-0.1-0.1-0.1-0.2V8.2c0-0.1,0.1-0.2,0.2-0.3c0.5-0.2,1-0.3,1.6-0.3c1.1,0,2.1,0.4,2.9,1.1 c0.8,0.8,1.3,1.7,1.4,2.8c0.3-0.1,0.6-0.2,1-0.2c0.7,0,1.3,0.2,1.7,0.7C21.8,12.6,22.1,13.2,22.1,13.9L22.1,13.9z"></path></svg>',
279
279
  ),
280
280
  'spotify' => array(
package/src/style.scss CHANGED
@@ -1,3 +1,4 @@
1
+ @import "./accordions/style.scss";
1
2
  @import "./archives/style.scss";
2
3
  @import "./avatar/style.scss";
3
4
  @import "./audio/style.scss";
@@ -6,26 +6,73 @@ import clsx from 'clsx';
6
6
  /**
7
7
  * WordPress dependencies
8
8
  */
9
- import { MediaUpload, MediaUploadCheck } from '@wordpress/block-editor';
9
+ import {
10
+ MediaUpload,
11
+ MediaUploadCheck,
12
+ store as blockEditorStore,
13
+ } from '@wordpress/block-editor';
14
+ import { store as noticesStore } from '@wordpress/notices';
10
15
  import {
11
16
  Button,
12
17
  BaseControl,
18
+ DropZone,
19
+ Spinner,
13
20
  __experimentalHStack as HStack,
14
21
  __experimentalToolsPanelItem as ToolsPanelItem,
15
22
  } from '@wordpress/components';
23
+ import { isBlobURL } from '@wordpress/blob';
16
24
  import { __, sprintf } from '@wordpress/i18n';
17
- import { useRef } from '@wordpress/element';
25
+ import { useRef, useState } from '@wordpress/element';
18
26
  import { useInstanceId } from '@wordpress/compose';
27
+ import { useSelect, useDispatch } from '@wordpress/data';
19
28
 
20
29
  const POSTER_IMAGE_ALLOWED_MEDIA_TYPES = [ 'image' ];
21
30
 
22
31
  function PosterImage( { poster, onChange } ) {
23
32
  const posterButtonRef = useRef();
33
+ const [ isLoading, setIsLoading ] = useState( false );
24
34
  const descriptionId = useInstanceId(
25
35
  PosterImage,
26
36
  'block-library-poster-image-description'
27
37
  );
28
38
 
39
+ const { getSettings } = useSelect( blockEditorStore );
40
+ const { createErrorNotice } = useDispatch( noticesStore );
41
+
42
+ const onDropFiles = ( filesList ) => {
43
+ getSettings().mediaUpload( {
44
+ allowedTypes: POSTER_IMAGE_ALLOWED_MEDIA_TYPES,
45
+ filesList,
46
+ onFileChange: ( [ image ] ) => {
47
+ if ( isBlobURL( image?.url ) ) {
48
+ setIsLoading( true );
49
+ return;
50
+ }
51
+
52
+ if ( image ) {
53
+ onChange( image );
54
+ }
55
+ setIsLoading( false );
56
+ },
57
+ onError: ( message ) => {
58
+ createErrorNotice( message, {
59
+ id: 'poster-image-upload-notice',
60
+ type: 'snackbar',
61
+ } );
62
+ setIsLoading( false );
63
+ },
64
+ multiple: false,
65
+ } );
66
+ };
67
+
68
+ const getPosterButtonContent = () => {
69
+ if ( ! poster && isLoading ) {
70
+ return <Spinner />;
71
+ }
72
+
73
+ return ! poster ? __( 'Set poster image' ) : __( 'Replace' );
74
+ };
75
+
29
76
  return (
30
77
  <MediaUploadCheck>
31
78
  <ToolsPanelItem
@@ -48,24 +95,19 @@ function PosterImage( { poster, onChange } ) {
48
95
  __next40pxDefaultSize
49
96
  onClick={ open }
50
97
  aria-haspopup="dialog"
51
- aria-label={
52
- ! poster
53
- ? null
54
- : __(
55
- 'Edit or replace the poster image.'
56
- )
57
- }
58
- className={
59
- poster
60
- ? 'block-library-poster-image__preview'
61
- : 'block-library-poster-image__toggle'
62
- }
98
+ aria-label={ __(
99
+ 'Edit or replace the poster image.'
100
+ ) }
101
+ className="block-library-poster-image__preview"
102
+ disabled={ isLoading }
103
+ accessibleWhenDisabled
63
104
  >
64
105
  <img
65
106
  src={ poster }
66
107
  alt={ __( 'Poster image preview' ) }
67
108
  className="block-library-poster-image__preview-image"
68
109
  />
110
+ { isLoading && <Spinner /> }
69
111
  </Button>
70
112
  ) }
71
113
  <HStack
@@ -87,10 +129,10 @@ function PosterImage( { poster, onChange } ) {
87
129
  variant={
88
130
  ! poster ? 'secondary' : undefined
89
131
  }
132
+ disabled={ isLoading }
133
+ accessibleWhenDisabled
90
134
  >
91
- { ! poster
92
- ? __( 'Set poster image' )
93
- : __( 'Replace' ) }
135
+ { getPosterButtonContent() }
94
136
  </Button>
95
137
  <p id={ descriptionId } hidden>
96
138
  { poster
@@ -115,11 +157,14 @@ function PosterImage( { poster, onChange } ) {
115
157
  posterButtonRef.current.focus();
116
158
  } }
117
159
  className="block-library-poster-image__action"
160
+ disabled={ isLoading }
161
+ accessibleWhenDisabled
118
162
  >
119
163
  { __( 'Remove' ) }
120
164
  </Button>
121
165
  ) }
122
166
  </HStack>
167
+ <DropZone onFilesDrop={ onDropFiles } />
123
168
  </div>
124
169
  ) }
125
170
  />