@wordpress/block-library 9.26.1-next.719a03cbe.0 → 9.27.1-next.46f643fa0.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 (170) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/build/categories/edit.js +15 -3
  3. package/build/categories/edit.js.map +1 -1
  4. package/build/cover/edit/block-controls.js +4 -2
  5. package/build/cover/edit/block-controls.js.map +1 -1
  6. package/build/cover/edit/index.js +6 -3
  7. package/build/cover/edit/index.js.map +1 -1
  8. package/build/cover/edit/inspector-controls.js +13 -4
  9. package/build/cover/edit/inspector-controls.js.map +1 -1
  10. package/build/cover/index.js +6 -0
  11. package/build/cover/index.js.map +1 -1
  12. package/build/cover/save.js +3 -1
  13. package/build/cover/save.js.map +1 -1
  14. package/build/file/edit.js +2 -1
  15. package/build/file/edit.js.map +1 -1
  16. package/build/latest-posts/edit.js +0 -2
  17. package/build/latest-posts/edit.js.map +1 -1
  18. package/build/media-text/edit.js +2 -2
  19. package/build/media-text/edit.js.map +1 -1
  20. package/build/navigation-link/edit.js +32 -15
  21. package/build/navigation-link/edit.js.map +1 -1
  22. package/build/navigation-link/update-attributes.js +112 -14
  23. package/build/navigation-link/update-attributes.js.map +1 -1
  24. package/build/navigation-submenu/edit.js +19 -2
  25. package/build/navigation-submenu/edit.js.map +1 -1
  26. package/build/paragraph/edit.js +2 -2
  27. package/build/paragraph/edit.js.map +1 -1
  28. package/build/post-content/edit.js +78 -16
  29. package/build/post-content/edit.js.map +1 -1
  30. package/build/post-content/index.js +6 -0
  31. package/build/post-content/index.js.map +1 -1
  32. package/build/post-date/deprecated.js +104 -1
  33. package/build/post-date/deprecated.js.map +1 -1
  34. package/build/post-date/edit.js +32 -32
  35. package/build/post-date/edit.js.map +1 -1
  36. package/build/post-date/index.js +4 -4
  37. package/build/post-date/index.js.map +1 -1
  38. package/build/post-date/variations.js +32 -3
  39. package/build/post-date/variations.js.map +1 -1
  40. package/build/separator/edit.js +5 -30
  41. package/build/separator/edit.js.map +1 -1
  42. package/build/site-tagline/index.js +1 -1
  43. package/build/social-link/variations.js +51 -49
  44. package/build/social-link/variations.js.map +1 -1
  45. package/build/utils/poster-image.js +93 -0
  46. package/build/utils/poster-image.js.map +1 -0
  47. package/build/video/edit.js +7 -6
  48. package/build/video/edit.js.map +1 -1
  49. package/build/video/tracks-editor.js +95 -104
  50. package/build/video/tracks-editor.js.map +1 -1
  51. package/build/video/tracks.js +6 -2
  52. package/build/video/tracks.js.map +1 -1
  53. package/build-module/categories/edit.js +15 -3
  54. package/build-module/categories/edit.js.map +1 -1
  55. package/build-module/cover/edit/block-controls.js +4 -2
  56. package/build-module/cover/edit/block-controls.js.map +1 -1
  57. package/build-module/cover/edit/index.js +6 -3
  58. package/build-module/cover/edit/index.js.map +1 -1
  59. package/build-module/cover/edit/inspector-controls.js +12 -4
  60. package/build-module/cover/edit/inspector-controls.js.map +1 -1
  61. package/build-module/cover/index.js +6 -0
  62. package/build-module/cover/index.js.map +1 -1
  63. package/build-module/cover/save.js +3 -1
  64. package/build-module/cover/save.js.map +1 -1
  65. package/build-module/file/edit.js +2 -1
  66. package/build-module/file/edit.js.map +1 -1
  67. package/build-module/latest-posts/edit.js +0 -2
  68. package/build-module/latest-posts/edit.js.map +1 -1
  69. package/build-module/media-text/edit.js +2 -2
  70. package/build-module/media-text/edit.js.map +1 -1
  71. package/build-module/navigation-link/edit.js +32 -15
  72. package/build-module/navigation-link/edit.js.map +1 -1
  73. package/build-module/navigation-link/update-attributes.js +113 -15
  74. package/build-module/navigation-link/update-attributes.js.map +1 -1
  75. package/build-module/navigation-submenu/edit.js +20 -3
  76. package/build-module/navigation-submenu/edit.js.map +1 -1
  77. package/build-module/paragraph/edit.js +2 -2
  78. package/build-module/paragraph/edit.js.map +1 -1
  79. package/build-module/post-content/edit.js +80 -18
  80. package/build-module/post-content/edit.js.map +1 -1
  81. package/build-module/post-content/index.js +6 -0
  82. package/build-module/post-content/index.js.map +1 -1
  83. package/build-module/post-date/deprecated.js +104 -1
  84. package/build-module/post-date/deprecated.js.map +1 -1
  85. package/build-module/post-date/edit.js +35 -35
  86. package/build-module/post-date/edit.js.map +1 -1
  87. package/build-module/post-date/index.js +4 -4
  88. package/build-module/post-date/index.js.map +1 -1
  89. package/build-module/post-date/variations.js +32 -3
  90. package/build-module/post-date/variations.js.map +1 -1
  91. package/build-module/separator/edit.js +6 -31
  92. package/build-module/separator/edit.js.map +1 -1
  93. package/build-module/site-tagline/index.js +1 -1
  94. package/build-module/social-link/variations.js +52 -50
  95. package/build-module/social-link/variations.js.map +1 -1
  96. package/build-module/utils/poster-image.js +85 -0
  97. package/build-module/utils/poster-image.js.map +1 -0
  98. package/build-module/video/edit.js +7 -6
  99. package/build-module/video/edit.js.map +1 -1
  100. package/build-module/video/tracks-editor.js +96 -105
  101. package/build-module/video/tracks-editor.js.map +1 -1
  102. package/build-module/video/tracks.js +6 -2
  103. package/build-module/video/tracks.js.map +1 -1
  104. package/build-style/archives/editor-rtl.css +0 -4
  105. package/build-style/archives/editor.css +0 -4
  106. package/build-style/editor-rtl.css +67 -18
  107. package/build-style/editor.css +67 -18
  108. package/build-style/file/style-rtl.css +1 -1
  109. package/build-style/file/style.css +1 -1
  110. package/build-style/navigation/editor-rtl.css +6 -6
  111. package/build-style/navigation/editor.css +6 -6
  112. package/build-style/navigation/style-rtl.css +1 -0
  113. package/build-style/navigation/style.css +1 -0
  114. package/build-style/page-list/editor-rtl.css +0 -4
  115. package/build-style/page-list/editor.css +0 -4
  116. package/build-style/style-rtl.css +3 -1
  117. package/build-style/style.css +3 -1
  118. package/build-style/video/editor-rtl.css +0 -4
  119. package/build-style/video/editor.css +0 -4
  120. package/build-style/video/style-rtl.css +1 -0
  121. package/build-style/video/style.css +1 -0
  122. package/package.json +35 -35
  123. package/src/archives/editor.scss +0 -4
  124. package/src/categories/edit.js +13 -1
  125. package/src/comments-pagination/index.php +7 -2
  126. package/src/cover/block.json +6 -0
  127. package/src/cover/edit/block-controls.js +22 -17
  128. package/src/cover/edit/index.js +4 -1
  129. package/src/cover/edit/inspector-controls.js +15 -2
  130. package/src/cover/save.js +2 -0
  131. package/src/editor.scss +1 -0
  132. package/src/file/edit.js +4 -1
  133. package/src/file/style.scss +1 -1
  134. package/src/latest-posts/edit.js +0 -2
  135. package/src/media-text/edit.js +1 -1
  136. package/src/navigation/style.scss +1 -0
  137. package/src/navigation-link/edit.js +28 -16
  138. package/src/navigation-link/test/edit.js +738 -6
  139. package/src/navigation-link/update-attributes.js +125 -12
  140. package/src/navigation-submenu/edit.js +21 -1
  141. package/src/page-list/editor.scss +0 -6
  142. package/src/paragraph/edit.js +2 -2
  143. package/src/post-content/block.json +6 -0
  144. package/src/post-content/edit.js +71 -19
  145. package/src/post-content/index.php +11 -4
  146. package/src/post-date/block.json +4 -4
  147. package/src/post-date/deprecated.js +104 -1
  148. package/src/post-date/edit.js +74 -86
  149. package/src/post-date/index.php +55 -28
  150. package/src/post-date/variations.js +37 -3
  151. package/src/post-featured-image/index.php +3 -2
  152. package/src/separator/edit.js +8 -43
  153. package/src/site-tagline/block.json +1 -1
  154. package/src/social-link/README.md +21 -0
  155. package/src/social-link/index.php +49 -49
  156. package/src/social-link/variations.js +51 -49
  157. package/src/utils/poster-image.js +131 -0
  158. package/src/utils/poster-image.scss +75 -0
  159. package/src/video/edit.js +8 -6
  160. package/src/video/editor.scss +0 -6
  161. package/src/video/index.php +91 -0
  162. package/src/video/style.native.scss +1 -0
  163. package/src/video/style.scss +1 -0
  164. package/src/video/tracks-editor.js +93 -103
  165. package/src/video/tracks.js +2 -1
  166. package/build/video/poster-image.js +0 -81
  167. package/build/video/poster-image.js.map +0 -1
  168. package/build-module/video/poster-image.js +0 -74
  169. package/build-module/video/poster-image.js.map +0 -1
  170. package/src/video/poster-image.js +0 -86
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * WordPress dependencies
3
3
  */
4
- import { __ } from '@wordpress/i18n';
4
+ import { _x } from '@wordpress/i18n';
5
5
 
6
6
  /**
7
7
  * Internal dependencies
@@ -62,292 +62,294 @@ const variations = [
62
62
  isDefault: true,
63
63
  name: 'wordpress',
64
64
  attributes: { service: 'wordpress' },
65
- title: __( 'WordPress' ),
65
+ title: _x( 'WordPress', 'social link block variation name' ),
66
66
  icon: WordPressIcon,
67
67
  },
68
68
 
69
69
  {
70
70
  name: 'fivehundredpx',
71
71
  attributes: { service: 'fivehundredpx' },
72
- title: __( '500px' ),
72
+ title: _x( '500px', 'social link block variation name' ),
73
73
  icon: FivehundredpxIcon,
74
74
  },
75
75
  {
76
76
  name: 'amazon',
77
77
  attributes: { service: 'amazon' },
78
- title: __( 'Amazon' ),
78
+ title: _x( 'Amazon', 'social link block variation name' ),
79
79
  icon: AmazonIcon,
80
80
  },
81
81
  {
82
82
  name: 'bandcamp',
83
83
  attributes: { service: 'bandcamp' },
84
- title: __( 'Bandcamp' ),
84
+ title: _x( 'Bandcamp', 'social link block variation name' ),
85
85
  icon: BandcampIcon,
86
86
  },
87
87
  {
88
88
  name: 'behance',
89
89
  attributes: { service: 'behance' },
90
- title: __( 'Behance' ),
90
+ title: _x( 'Behance', 'social link block variation name' ),
91
91
  icon: BehanceIcon,
92
92
  },
93
93
  {
94
94
  name: 'bluesky',
95
95
  attributes: { service: 'bluesky' },
96
- title: __( 'Bluesky' ),
96
+ title: _x( 'Bluesky', 'social link block variation name' ),
97
97
  icon: BlueskyIcon,
98
98
  },
99
99
  {
100
100
  name: 'chain',
101
101
  attributes: { service: 'chain' },
102
- title: __( 'Link' ),
102
+ title: _x( 'Link', 'social link block variation name' ),
103
103
  icon: ChainIcon,
104
104
  },
105
105
  {
106
106
  name: 'codepen',
107
107
  attributes: { service: 'codepen' },
108
- title: __( 'CodePen' ),
108
+ title: _x( 'CodePen', 'social link block variation name' ),
109
109
  icon: CodepenIcon,
110
110
  },
111
111
  {
112
112
  name: 'deviantart',
113
113
  attributes: { service: 'deviantart' },
114
- title: __( 'DeviantArt' ),
114
+ title: _x( 'DeviantArt', 'social link block variation name' ),
115
115
  icon: DeviantArtIcon,
116
116
  },
117
117
  {
118
118
  name: 'discord',
119
119
  attributes: { service: 'discord' },
120
- title: __( 'Discord' ),
120
+ title: _x( 'Discord', 'social link block variation name' ),
121
121
  icon: DiscordIcon,
122
122
  },
123
123
  {
124
124
  name: 'dribbble',
125
125
  attributes: { service: 'dribbble' },
126
- title: __( 'Dribbble' ),
126
+ title: _x( 'Dribbble', 'social link block variation name' ),
127
127
  icon: DribbbleIcon,
128
128
  },
129
129
  {
130
130
  name: 'dropbox',
131
131
  attributes: { service: 'dropbox' },
132
- title: __( 'Dropbox' ),
132
+ title: _x( 'Dropbox', 'social link block variation name' ),
133
133
  icon: DropboxIcon,
134
134
  },
135
135
  {
136
136
  name: 'etsy',
137
137
  attributes: { service: 'etsy' },
138
- title: __( 'Etsy' ),
138
+ title: _x( 'Etsy', 'social link block variation name' ),
139
139
  icon: EtsyIcon,
140
140
  },
141
141
  {
142
142
  name: 'facebook',
143
143
  attributes: { service: 'facebook' },
144
- title: __( 'Facebook' ),
144
+ title: _x( 'Facebook', 'social link block variation name' ),
145
145
  icon: FacebookIcon,
146
146
  },
147
147
  {
148
148
  name: 'feed',
149
149
  attributes: { service: 'feed' },
150
- title: __( 'RSS Feed' ),
150
+ title: _x( 'RSS Feed', 'social link block variation name' ),
151
151
  icon: FeedIcon,
152
152
  },
153
153
  {
154
154
  name: 'flickr',
155
155
  attributes: { service: 'flickr' },
156
- title: __( 'Flickr' ),
156
+ title: _x( 'Flickr', 'social link block variation name' ),
157
157
  icon: FlickrIcon,
158
158
  },
159
159
  {
160
160
  name: 'foursquare',
161
161
  attributes: { service: 'foursquare' },
162
- title: __( 'Foursquare' ),
162
+ title: _x( 'Foursquare', 'social link block variation name' ),
163
163
  icon: FoursquareIcon,
164
164
  },
165
165
  {
166
166
  name: 'goodreads',
167
167
  attributes: { service: 'goodreads' },
168
- title: __( 'Goodreads' ),
168
+ title: _x( 'Goodreads', 'social link block variation name' ),
169
169
  icon: GoodreadsIcon,
170
170
  },
171
171
  {
172
172
  name: 'google',
173
173
  attributes: { service: 'google' },
174
- title: __( 'Google' ),
174
+ title: _x( 'Google', 'social link block variation name' ),
175
175
  icon: GoogleIcon,
176
176
  },
177
177
  {
178
178
  name: 'github',
179
179
  attributes: { service: 'github' },
180
- title: __( 'GitHub' ),
180
+ title: _x( 'GitHub', 'social link block variation name' ),
181
181
  icon: GitHubIcon,
182
182
  },
183
183
  {
184
184
  name: 'gravatar',
185
185
  attributes: { service: 'gravatar' },
186
- title: __( 'Gravatar' ),
186
+ title: _x( 'Gravatar', 'social link block variation name' ),
187
187
  icon: GravatarIcon,
188
188
  },
189
189
  {
190
190
  name: 'instagram',
191
191
  attributes: { service: 'instagram' },
192
- title: __( 'Instagram' ),
192
+ title: _x( 'Instagram', 'social link block variation name' ),
193
193
  icon: InstagramIcon,
194
194
  },
195
195
  {
196
196
  name: 'lastfm',
197
197
  attributes: { service: 'lastfm' },
198
- title: __( 'Last.fm' ),
198
+ title: _x( 'Last.fm', 'social link block variation name' ),
199
199
  icon: LastfmIcon,
200
200
  },
201
201
  {
202
202
  name: 'linkedin',
203
203
  attributes: { service: 'linkedin' },
204
- title: __( 'LinkedIn' ),
204
+ title: _x( 'LinkedIn', 'social link block variation name' ),
205
205
  icon: LinkedInIcon,
206
206
  },
207
207
  {
208
208
  name: 'mail',
209
209
  attributes: { service: 'mail' },
210
- title: __( 'Mail' ),
210
+ title: _x( 'Mail', 'social link block variation name' ),
211
211
  keywords: [ 'email', 'e-mail' ],
212
212
  icon: MailIcon,
213
213
  },
214
214
  {
215
215
  name: 'mastodon',
216
216
  attributes: { service: 'mastodon' },
217
- title: __( 'Mastodon' ),
217
+ title: _x( 'Mastodon', 'social link block variation name' ),
218
218
  icon: MastodonIcon,
219
219
  },
220
220
  {
221
221
  name: 'meetup',
222
222
  attributes: { service: 'meetup' },
223
- title: __( 'Meetup' ),
223
+ title: _x( 'Meetup', 'social link block variation name' ),
224
224
  icon: MeetupIcon,
225
225
  },
226
226
  {
227
227
  name: 'medium',
228
228
  attributes: { service: 'medium' },
229
- title: __( 'Medium' ),
229
+ title: _x( 'Medium', 'social link block variation name' ),
230
230
  icon: MediumIcon,
231
231
  },
232
232
  {
233
233
  name: 'patreon',
234
234
  attributes: { service: 'patreon' },
235
- title: __( 'Patreon' ),
235
+ title: _x( 'Patreon', 'social link block variation name' ),
236
236
  icon: PatreonIcon,
237
237
  },
238
238
  {
239
239
  name: 'pinterest',
240
240
  attributes: { service: 'pinterest' },
241
- title: __( 'Pinterest' ),
241
+ title: _x( 'Pinterest', 'social link block variation name' ),
242
242
  icon: PinterestIcon,
243
243
  },
244
244
  {
245
245
  name: 'pocket',
246
246
  attributes: { service: 'pocket' },
247
- title: __( 'Pocket' ),
247
+ title: _x( 'Pocket', 'social link block variation name' ),
248
248
  icon: PocketIcon,
249
249
  },
250
250
  {
251
251
  name: 'reddit',
252
252
  attributes: { service: 'reddit' },
253
- title: __( 'Reddit' ),
253
+ title: _x( 'Reddit', 'social link block variation name' ),
254
254
  icon: RedditIcon,
255
255
  },
256
256
  {
257
257
  name: 'skype',
258
258
  attributes: { service: 'skype' },
259
- title: __( 'Skype' ),
259
+ title: _x( 'Skype', 'social link block variation name' ),
260
260
  icon: SkypeIcon,
261
+ // Deprecated: Skype service is no longer available.
262
+ scope: [],
261
263
  },
262
264
  {
263
265
  name: 'snapchat',
264
266
  attributes: { service: 'snapchat' },
265
- title: __( 'Snapchat' ),
267
+ title: _x( 'Snapchat', 'social link block variation name' ),
266
268
  icon: SnapchatIcon,
267
269
  },
268
270
  {
269
271
  name: 'soundcloud',
270
272
  attributes: { service: 'soundcloud' },
271
- title: __( 'SoundCloud' ),
273
+ title: _x( 'SoundCloud', 'social link block variation name' ),
272
274
  icon: SoundCloudIcon,
273
275
  },
274
276
  {
275
277
  name: 'spotify',
276
278
  attributes: { service: 'spotify' },
277
- title: __( 'Spotify' ),
279
+ title: _x( 'Spotify', 'social link block variation name' ),
278
280
  icon: SpotifyIcon,
279
281
  },
280
282
  {
281
283
  name: 'telegram',
282
284
  attributes: { service: 'telegram' },
283
- title: __( 'Telegram' ),
285
+ title: _x( 'Telegram', 'social link block variation name' ),
284
286
  icon: TelegramIcon,
285
287
  },
286
288
  {
287
289
  name: 'threads',
288
290
  attributes: { service: 'threads' },
289
- title: __( 'Threads' ),
291
+ title: _x( 'Threads', 'social link block variation name' ),
290
292
  icon: ThreadsIcon,
291
293
  },
292
294
  {
293
295
  name: 'tiktok',
294
296
  attributes: { service: 'tiktok' },
295
- title: __( 'TikTok' ),
297
+ title: _x( 'TikTok', 'social link block variation name' ),
296
298
  icon: TiktokIcon,
297
299
  },
298
300
  {
299
301
  name: 'tumblr',
300
302
  attributes: { service: 'tumblr' },
301
- title: __( 'Tumblr' ),
303
+ title: _x( 'Tumblr', 'social link block variation name' ),
302
304
  icon: TumblrIcon,
303
305
  },
304
306
  {
305
307
  name: 'twitch',
306
308
  attributes: { service: 'twitch' },
307
- title: __( 'Twitch' ),
309
+ title: _x( 'Twitch', 'social link block variation name' ),
308
310
  icon: TwitchIcon,
309
311
  },
310
312
  {
311
313
  name: 'twitter',
312
314
  attributes: { service: 'twitter' },
313
- title: __( 'Twitter' ),
315
+ title: _x( 'Twitter', 'social link block variation name' ),
314
316
  icon: TwitterIcon,
315
317
  },
316
318
  {
317
319
  name: 'vimeo',
318
320
  attributes: { service: 'vimeo' },
319
- title: __( 'Vimeo' ),
321
+ title: _x( 'Vimeo', 'social link block variation name' ),
320
322
  icon: VimeoIcon,
321
323
  },
322
324
  {
323
325
  name: 'vk',
324
326
  attributes: { service: 'vk' },
325
- title: __( 'VK' ),
327
+ title: _x( 'VK', 'social link block variation name' ),
326
328
  icon: VkIcon,
327
329
  },
328
330
  {
329
331
  name: 'whatsapp',
330
332
  attributes: { service: 'whatsapp' },
331
- title: __( 'WhatsApp' ),
333
+ title: _x( 'WhatsApp', 'social link block variation name' ),
332
334
  icon: WhatsAppIcon,
333
335
  },
334
336
  {
335
337
  name: 'x',
336
338
  attributes: { service: 'x' },
337
339
  keywords: [ 'twitter' ],
338
- title: __( 'X' ),
340
+ title: _x( 'X', 'social link block variation name' ),
339
341
  icon: XIcon,
340
342
  },
341
343
  {
342
344
  name: 'yelp',
343
345
  attributes: { service: 'yelp' },
344
- title: __( 'Yelp' ),
346
+ title: _x( 'Yelp', 'social link block variation name' ),
345
347
  icon: YelpIcon,
346
348
  },
347
349
  {
348
350
  name: 'youtube',
349
351
  attributes: { service: 'youtube' },
350
- title: __( 'YouTube' ),
352
+ title: _x( 'YouTube', 'social link block variation name' ),
351
353
  icon: YouTubeIcon,
352
354
  },
353
355
  ];
@@ -0,0 +1,131 @@
1
+ /**
2
+ * External dependencies
3
+ */
4
+ import clsx from 'clsx';
5
+
6
+ /**
7
+ * WordPress dependencies
8
+ */
9
+ import { MediaUpload, MediaUploadCheck } from '@wordpress/block-editor';
10
+ import {
11
+ Button,
12
+ BaseControl,
13
+ __experimentalHStack as HStack,
14
+ __experimentalToolsPanelItem as ToolsPanelItem,
15
+ } from '@wordpress/components';
16
+ import { __, sprintf } from '@wordpress/i18n';
17
+ import { useRef } from '@wordpress/element';
18
+ import { useInstanceId } from '@wordpress/compose';
19
+
20
+ const POSTER_IMAGE_ALLOWED_MEDIA_TYPES = [ 'image' ];
21
+
22
+ function PosterImage( { poster, onChange } ) {
23
+ const posterButtonRef = useRef();
24
+ const descriptionId = useInstanceId(
25
+ PosterImage,
26
+ 'block-library-poster-image-description'
27
+ );
28
+
29
+ return (
30
+ <MediaUploadCheck>
31
+ <ToolsPanelItem
32
+ label={ __( 'Poster image' ) }
33
+ isShownByDefault
34
+ hasValue={ () => !! poster }
35
+ onDeselect={ () => onChange( undefined ) }
36
+ >
37
+ <BaseControl.VisualLabel>
38
+ { __( 'Poster image' ) }
39
+ </BaseControl.VisualLabel>
40
+ <MediaUpload
41
+ title={ __( 'Select poster image' ) }
42
+ onSelect={ onChange }
43
+ allowedTypes={ POSTER_IMAGE_ALLOWED_MEDIA_TYPES }
44
+ render={ ( { open } ) => (
45
+ <div className="block-library-poster-image__container">
46
+ { poster && (
47
+ <Button
48
+ __next40pxDefaultSize
49
+ onClick={ open }
50
+ 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
+ }
63
+ >
64
+ <img
65
+ src={ poster }
66
+ alt={ __( 'Poster image preview' ) }
67
+ className="block-library-poster-image__preview-image"
68
+ />
69
+ </Button>
70
+ ) }
71
+ <HStack
72
+ className={ clsx(
73
+ 'block-library-poster-image__actions',
74
+ {
75
+ 'block-library-poster-image__actions-select':
76
+ ! poster,
77
+ }
78
+ ) }
79
+ >
80
+ <Button
81
+ __next40pxDefaultSize
82
+ onClick={ open }
83
+ ref={ posterButtonRef }
84
+ className="block-library-poster-image__action"
85
+ aria-describedby={ descriptionId }
86
+ aria-haspopup="dialog"
87
+ variant={
88
+ ! poster ? 'secondary' : undefined
89
+ }
90
+ >
91
+ { ! poster
92
+ ? __( 'Set poster image' )
93
+ : __( 'Replace' ) }
94
+ </Button>
95
+ <p id={ descriptionId } hidden>
96
+ { poster
97
+ ? sprintf(
98
+ /* translators: %s: poster image URL. */
99
+ __(
100
+ 'The current poster image url is %s.'
101
+ ),
102
+ poster
103
+ )
104
+ : __(
105
+ 'There is no poster image currently selected.'
106
+ ) }
107
+ </p>
108
+ { !! poster && (
109
+ <Button
110
+ __next40pxDefaultSize
111
+ onClick={ () => {
112
+ onChange( undefined );
113
+
114
+ // Move focus back to the Media Upload button.
115
+ posterButtonRef.current.focus();
116
+ } }
117
+ className="block-library-poster-image__action"
118
+ >
119
+ { __( 'Remove' ) }
120
+ </Button>
121
+ ) }
122
+ </HStack>
123
+ </div>
124
+ ) }
125
+ />
126
+ </ToolsPanelItem>
127
+ </MediaUploadCheck>
128
+ );
129
+ }
130
+
131
+ export default PosterImage;
@@ -0,0 +1,75 @@
1
+ .block-library-poster-image__container {
2
+ position: relative;
3
+
4
+ &:hover,
5
+ &:focus,
6
+ &:focus-within {
7
+ .block-library-poster-image__actions {
8
+ opacity: 1;
9
+ }
10
+ }
11
+
12
+ .block-library-poster-image__actions.block-library-poster-image__actions-select {
13
+ opacity: 1;
14
+ margin-top: $grid-unit-20;
15
+ }
16
+ }
17
+
18
+ .block-library-poster-image__toggle,
19
+ .block-library-poster-image__preview {
20
+ width: 100%;
21
+ padding: 0;
22
+ overflow: hidden; // Ensure the focus style properly encapsulates the image.
23
+ outline-offset: -#{$border-width};
24
+ min-height: $grid-unit-50;
25
+
26
+ display: flex;
27
+ justify-content: center;
28
+ }
29
+
30
+ .block-library-poster-image__preview {
31
+ height: auto !important;
32
+ outline: $border-width solid rgba($black, 0.1);
33
+
34
+ .block-library-poster-image__preview-image {
35
+ object-fit: cover;
36
+ width: 100%;
37
+ object-position: 50% 50%;
38
+ aspect-ratio: 2/1;
39
+ }
40
+ }
41
+
42
+ .block-library-poster-image__toggle {
43
+ box-shadow: inset 0 0 0 $border-width $gray-400;
44
+
45
+ &:focus:not(:disabled) {
46
+ // Allow smooth transition between focused and unfocused box-shadow states.
47
+ box-shadow:
48
+ 0 0 0 currentColor inset,
49
+ 0 0 0 var(--wp-admin-border-width-focus)
50
+ var(--wp-admin-theme-color);
51
+ }
52
+ }
53
+
54
+ .block-library-poster-image__actions {
55
+ &:not(.block-library-poster-image__actions-select) {
56
+ bottom: 0;
57
+ opacity: 0; // Use opacity instead of visibility so that the buttons remain in the tab order.
58
+ padding: $grid-unit-10;
59
+ position: absolute;
60
+
61
+ @media not ( prefers-reduced-motion ) {
62
+ transition: opacity 50ms ease-out;
63
+ }
64
+
65
+ .block-library-poster-image__action {
66
+ backdrop-filter: blur(16px) saturate(180%);
67
+ background: rgba(255, 255, 255, 0.75);
68
+ }
69
+ }
70
+
71
+ .block-library-poster-image__action {
72
+ flex-grow: 1;
73
+ justify-content: center;
74
+ }
75
+ }
package/src/video/edit.js CHANGED
@@ -23,7 +23,6 @@ import {
23
23
  } from '@wordpress/block-editor';
24
24
  import { useRef, useEffect, useState } from '@wordpress/element';
25
25
  import { __ } from '@wordpress/i18n';
26
- import { useInstanceId } from '@wordpress/compose';
27
26
  import { useDispatch } from '@wordpress/data';
28
27
  import { video as icon } from '@wordpress/icons';
29
28
  import { store as noticesStore } from '@wordpress/notices';
@@ -31,7 +30,6 @@ import { store as noticesStore } from '@wordpress/notices';
31
30
  /**
32
31
  * Internal dependencies
33
32
  */
34
- import PosterImage from './poster-image';
35
33
  import { createUpgradedEmbedBlock } from '../embed/util';
36
34
  import {
37
35
  useUploadMediaFromBlobURL,
@@ -41,6 +39,7 @@ import VideoCommonSettings from './edit-common-settings';
41
39
  import TracksEditor from './tracks-editor';
42
40
  import Tracks from './tracks';
43
41
  import { Caption } from '../utils/caption';
42
+ import PosterImage from '../utils/poster-image';
44
43
 
45
44
  const ALLOWED_MEDIA_TYPES = [ 'video' ];
46
45
 
@@ -52,7 +51,6 @@ function VideoEdit( {
52
51
  insertBlocksAfter,
53
52
  onReplace,
54
53
  } ) {
55
- const instanceId = useInstanceId( VideoEdit );
56
54
  const videoPlayer = useRef();
57
55
  const { id, controls, poster, src, tracks } = attributes;
58
56
  const [ temporaryURL, setTemporaryURL ] = useState( attributes.blob );
@@ -72,6 +70,7 @@ function VideoEdit( {
72
70
  }
73
71
  }, [ poster ] );
74
72
 
73
+ // TODO: Whether the video was obtained from the media library or was provided by URL, obtain the `videoWidth` and `videoHeight` of the video once its metadata has loaded and persist in the block attributes.
75
74
  function onSelectVideo( media ) {
76
75
  if ( ! media || ! media.url ) {
77
76
  // In this case there was an error
@@ -210,7 +209,7 @@ function VideoEdit( {
210
209
  muted: false,
211
210
  playsInline: false,
212
211
  preload: 'metadata',
213
- poster: '',
212
+ poster: undefined,
214
213
  } );
215
214
  } }
216
215
  dropdownMenuProps={ dropdownMenuProps }
@@ -221,8 +220,11 @@ function VideoEdit( {
221
220
  />
222
221
  <PosterImage
223
222
  poster={ poster }
224
- setAttributes={ setAttributes }
225
- instanceId={ instanceId }
223
+ onChange={ ( posterImage ) =>
224
+ setAttributes( {
225
+ poster: posterImage?.url,
226
+ } )
227
+ }
226
228
  />
227
229
  </ToolsPanel>
228
230
  </InspectorControls>
@@ -19,12 +19,6 @@
19
19
  }
20
20
  }
21
21
 
22
- .editor-video-poster-control {
23
- .components-button {
24
- margin-right: $grid-unit-10;
25
- }
26
- }
27
-
28
22
  .block-library-video-tracks-editor {
29
23
  z-index: z-index("{core/video track editor popover}");
30
24
  }