@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
@@ -0,0 +1,91 @@
1
+ <?php
2
+ /**
3
+ * Server-side rendering of the `core/video` block.
4
+ *
5
+ * @package WordPress
6
+ */
7
+
8
+ /**
9
+ * Renders the `core/video` block on the server to supply the width and height attributes from the attachment metadata.
10
+ *
11
+ * @since 6.9.0
12
+ *
13
+ * @phpstan-param array{ "id"?: positive-int } $attributes
14
+ *
15
+ * @param array $attributes The block attributes.
16
+ * @param string $content The block content.
17
+ * @return string The block content with the dimensions added.
18
+ */
19
+ function render_block_core_video( array $attributes, string $content ): string {
20
+ // if the content lacks any video tag, abort.
21
+ if ( ! str_contains( $content, '<video' ) ) {
22
+ return $content;
23
+ }
24
+
25
+ // If the 'id' attribute is not populated for a video attachment, abort.
26
+ if (
27
+ ! isset( $attributes['id'] ) ||
28
+ ! is_int( $attributes['id'] ) ||
29
+ $attributes['id'] <= 0
30
+ ) {
31
+ return $content;
32
+ }
33
+
34
+ // If the 'id' attribute wasn't for an attachment, abort.
35
+ if ( get_post_type( $attributes['id'] ) !== 'attachment' ) {
36
+ return $content;
37
+ }
38
+
39
+ // Get the width and height metadata for the video, and abort if absent or invalid.
40
+ $metadata = wp_get_attachment_metadata( $attributes['id'] );
41
+ if (
42
+ ! isset( $metadata['width'], $metadata['height'] ) ||
43
+ ! ( is_int( $metadata['width'] ) && is_int( $metadata['height'] ) ) ||
44
+ ! ( $metadata['width'] > 0 && $metadata['height'] > 0 )
45
+ ) {
46
+ return $content;
47
+ }
48
+
49
+ // Locate the VIDEO tag to add the dimensions.
50
+ $p = new WP_HTML_Tag_Processor( $content );
51
+ if ( ! $p->next_tag( array( 'tag_name' => 'VIDEO' ) ) ) {
52
+ return $content;
53
+ }
54
+
55
+ $p->set_attribute( 'width', (string) $metadata['width'] );
56
+ $p->set_attribute( 'height', (string) $metadata['height'] );
57
+
58
+ /*
59
+ * The aspect-ratio style is needed due to an issue with the CSS spec: <https://github.com/w3c/csswg-drafts/issues/7524>.
60
+ * Note that a style rule using attr() like the following cannot currently be used:
61
+ *
62
+ * .wp-block-video video[width][height] {
63
+ * aspect-ratio: attr(width type(<number>)) / attr(height type(<number>));
64
+ * }
65
+ *
66
+ * This is because this attr() is yet only implemented in Chromium: <https://caniuse.com/css3-attr>.
67
+ */
68
+ $style = $p->get_attribute( 'style' );
69
+ if ( ! is_string( $style ) ) {
70
+ $style = '';
71
+ }
72
+ $aspect_ratio_style = sprintf( 'aspect-ratio: %d / %d;', $metadata['width'], $metadata['height'] );
73
+ $p->set_attribute( 'style', $aspect_ratio_style . $style );
74
+
75
+ return $p->get_updated_html();
76
+ }
77
+
78
+ /**
79
+ * Registers the `core/video` block on server.
80
+ *
81
+ * @since 6.9.0
82
+ */
83
+ function register_block_core_video(): void {
84
+ register_block_type_from_metadata(
85
+ __DIR__ . '/video',
86
+ array(
87
+ 'render_callback' => 'render_block_core_video',
88
+ )
89
+ );
90
+ }
91
+ add_action( 'init', 'register_block_core_video' );
@@ -2,6 +2,7 @@
2
2
 
3
3
  .video {
4
4
  width: 100%;
5
+ height: auto;
5
6
  }
6
7
 
7
8
  .videoContainer {
@@ -3,6 +3,7 @@
3
3
  box-sizing: border-box;
4
4
  video {
5
5
  width: 100%;
6
+ height: auto;
6
7
  vertical-align: middle;
7
8
  }
8
9
 
@@ -24,9 +24,8 @@ import {
24
24
  MediaUploadCheck,
25
25
  store as blockEditorStore,
26
26
  } from '@wordpress/block-editor';
27
- import { store as noticesStore } from '@wordpress/notices';
28
27
  import { upload, media } from '@wordpress/icons';
29
- import { useSelect, useDispatch } from '@wordpress/data';
28
+ import { useSelect } from '@wordpress/data';
30
29
  import { useState, useRef, useEffect } from '@wordpress/element';
31
30
  import { getFilename } from '@wordpress/url';
32
31
 
@@ -49,11 +48,19 @@ const KIND_OPTIONS = [
49
48
  { label: __( 'Metadata' ), value: 'metadata' },
50
49
  ];
51
50
 
51
+ const DEFAULT_TRACK = {
52
+ src: '',
53
+ label: '',
54
+ srcLang: 'en',
55
+ kind: DEFAULT_KIND,
56
+ default: false,
57
+ };
58
+
52
59
  function TrackList( { tracks, onEditPress } ) {
53
60
  const content = tracks.map( ( track, index ) => {
54
61
  return (
55
62
  <HStack
56
- key={ track.src }
63
+ key={ track.id ?? track.src }
57
64
  className="block-library-video-tracks-editor__track-list-track"
58
65
  >
59
66
  <span>{ track.label }</span>
@@ -93,13 +100,12 @@ function SingleTrackEditor( {
93
100
  onRemove,
94
101
  allowSettingDefault,
95
102
  } ) {
96
- const {
97
- src = '',
98
- label = '',
99
- srcLang = '',
100
- kind = DEFAULT_KIND,
101
- default: isDefaultTrack = false,
102
- } = track;
103
+ const [ trackState, setTrackState ] = useState( {
104
+ ...DEFAULT_TRACK,
105
+ ...track,
106
+ } );
107
+
108
+ const { src, label, srcLang, kind, default: isDefaultTrack } = trackState;
103
109
  const fileName = src.startsWith( 'blob:' ) ? '' : getFilename( src ) || '';
104
110
  return (
105
111
  <VStack
@@ -117,10 +123,10 @@ function SingleTrackEditor( {
117
123
  __next40pxDefaultSize
118
124
  __nextHasNoMarginBottom
119
125
  onChange={ ( newLabel ) =>
120
- onChange( {
121
- ...track,
126
+ setTrackState( ( prevTrackState ) => ( {
127
+ ...prevTrackState,
122
128
  label: newLabel,
123
- } )
129
+ } ) )
124
130
  }
125
131
  label={ __( 'Label' ) }
126
132
  value={ label }
@@ -130,10 +136,10 @@ function SingleTrackEditor( {
130
136
  __next40pxDefaultSize
131
137
  __nextHasNoMarginBottom
132
138
  onChange={ ( newSrcLang ) =>
133
- onChange( {
134
- ...track,
139
+ setTrackState( ( prevTrackState ) => ( {
140
+ ...prevTrackState,
135
141
  srcLang: newSrcLang,
136
- } )
142
+ } ) )
137
143
  }
138
144
  label={ __( 'Source language' ) }
139
145
  value={ srcLang }
@@ -148,12 +154,12 @@ function SingleTrackEditor( {
148
154
  options={ KIND_OPTIONS }
149
155
  value={ kind }
150
156
  label={ __( 'Kind' ) }
151
- onChange={ ( newKind ) => {
152
- onChange( {
153
- ...track,
157
+ onChange={ ( newKind ) =>
158
+ setTrackState( ( prevTrackState ) => ( {
159
+ ...prevTrackState,
154
160
  kind: newKind,
155
- } );
156
- } }
161
+ } ) )
162
+ }
157
163
  />
158
164
  <ToggleControl
159
165
  __next40pxDefaultSize
@@ -161,12 +167,12 @@ function SingleTrackEditor( {
161
167
  label={ __( 'Set as default track' ) }
162
168
  checked={ isDefaultTrack }
163
169
  disabled={ ! allowSettingDefault }
164
- onChange={ ( defaultTrack ) => {
165
- onChange( {
166
- ...track,
170
+ onChange={ ( defaultTrack ) =>
171
+ setTrackState( ( prevTrackState ) => ( {
172
+ ...prevTrackState,
167
173
  default: defaultTrack,
168
- } );
169
- } }
174
+ } ) )
175
+ }
170
176
  />
171
177
  <HStack className="block-library-video-tracks-editor__single-track-editor-buttons-container">
172
178
  <Button
@@ -181,26 +187,7 @@ function SingleTrackEditor( {
181
187
  __next40pxDefaultSize
182
188
  variant="primary"
183
189
  onClick={ () => {
184
- const changes = {};
185
- let hasChanges = false;
186
- if ( label === '' ) {
187
- changes.label = __( 'English' );
188
- hasChanges = true;
189
- }
190
- if ( srcLang === '' ) {
191
- changes.srcLang = 'en';
192
- hasChanges = true;
193
- }
194
- if ( track.kind === undefined ) {
195
- changes.kind = DEFAULT_KIND;
196
- hasChanges = true;
197
- }
198
- if ( hasChanges ) {
199
- onChange( {
200
- ...track,
201
- ...changes,
202
- } );
203
- }
190
+ onChange( trackState );
204
191
  onClose();
205
192
  } }
206
193
  >
@@ -213,27 +200,60 @@ function SingleTrackEditor( {
213
200
  }
214
201
 
215
202
  export default function TracksEditor( { tracks = [], onChange } ) {
216
- const { createNotice } = useDispatch( noticesStore );
217
203
  const mediaUpload = useSelect( ( select ) => {
218
204
  return select( blockEditorStore ).getSettings().mediaUpload;
219
205
  }, [] );
220
206
  const [ trackBeingEdited, setTrackBeingEdited ] = useState( null );
221
207
  const dropdownPopoverRef = useRef();
222
208
 
223
- const handleTrackSelect = ( { title, url } ) => {
224
- if ( tracks.some( ( track ) => track.src === url ) ) {
225
- createNotice( 'error', __( 'This track already exists.' ), {
226
- isDismissible: true,
227
- type: 'snackbar',
228
- } );
209
+ const handleTrackSelect = ( selectedTracks = [], appendTracks = false ) => {
210
+ const existingTracksMap = new Map(
211
+ tracks.map( ( track ) => [ track.id, track ] )
212
+ );
213
+ const tracksToAdd = selectedTracks.map( ( { id, title, url } ) => {
214
+ // Reuse existing tracks to preserve user-configured metadata.
215
+ if ( existingTracksMap.has( id ) ) {
216
+ return existingTracksMap.get( id );
217
+ }
218
+
219
+ return {
220
+ ...DEFAULT_TRACK,
221
+ id,
222
+ label: title || '',
223
+ src: url,
224
+ };
225
+ } );
226
+
227
+ if ( tracksToAdd.length === 0 ) {
229
228
  return;
230
229
  }
231
230
 
232
- const trackIndex = tracks.length;
233
- onChange( [ ...tracks, { label: title || '', src: url } ] );
234
- setTrackBeingEdited( trackIndex );
231
+ onChange( [ ...( appendTracks ? tracks : [] ), ...tracksToAdd ] );
235
232
  };
236
233
 
234
+ function uploadFiles( event ) {
235
+ const files = event.target.files;
236
+ mediaUpload( {
237
+ allowedTypes: ALLOWED_TYPES,
238
+ filesList: files,
239
+ onFileChange: ( selectedTracks ) => {
240
+ if ( ! Array.isArray( selectedTracks ) ) {
241
+ return;
242
+ }
243
+
244
+ // Wait until the track has been uploaded.
245
+ const uploadedTracks = selectedTracks.filter(
246
+ ( track ) => !! track?.id
247
+ );
248
+
249
+ if ( ! uploadedTracks.length ) {
250
+ return;
251
+ }
252
+ handleTrackSelect( uploadedTracks, true );
253
+ },
254
+ } );
255
+ }
256
+
237
257
  useEffect( () => {
238
258
  dropdownPopoverRef.current?.focus();
239
259
  }, [ trackBeingEdited ] );
@@ -321,60 +341,30 @@ export default function TracksEditor( { tracks = [], onChange } ) {
321
341
  className="block-library-video-tracks-editor__add-tracks-container"
322
342
  label={ __( 'Add tracks' ) }
323
343
  >
324
- <MediaUpload
325
- onSelect={ handleTrackSelect }
326
- allowedTypes={ ALLOWED_TYPES }
327
- render={ ( { open } ) => (
328
- <MenuItem
329
- icon={ media }
330
- onClick={ open }
331
- >
332
- { __( 'Open Media Library' ) }
333
- </MenuItem>
334
- ) }
335
- />
336
344
  <MediaUploadCheck>
345
+ <MediaUpload
346
+ onSelect={ handleTrackSelect }
347
+ allowedTypes={ ALLOWED_TYPES }
348
+ value={ tracks.map( ( { id } ) => id ) }
349
+ multiple
350
+ render={ ( { open } ) => (
351
+ <MenuItem
352
+ icon={ media }
353
+ onClick={ open }
354
+ >
355
+ { __( 'Open Media Library' ) }
356
+ </MenuItem>
357
+ ) }
358
+ />
337
359
  <FormFileUpload
338
- onChange={ ( event ) => {
339
- const files = event.target.files;
340
- const trackIndex = tracks.length;
341
- mediaUpload( {
342
- allowedTypes: ALLOWED_TYPES,
343
- filesList: files,
344
- onFileChange: ( [
345
- { url },
346
- ] ) => {
347
- const newTracks = [
348
- ...tracks,
349
- ];
350
- if (
351
- ! newTracks[
352
- trackIndex
353
- ]
354
- ) {
355
- newTracks[
356
- trackIndex
357
- ] = {};
358
- }
359
- newTracks[ trackIndex ] = {
360
- ...tracks[ trackIndex ],
361
- src: url,
362
- };
363
- onChange( newTracks );
364
- setTrackBeingEdited(
365
- trackIndex
366
- );
367
- },
368
- } );
369
- } }
360
+ onChange={ uploadFiles }
370
361
  accept=".vtt,text/vtt"
362
+ multiple
371
363
  render={ ( { openFileDialog } ) => {
372
364
  return (
373
365
  <MenuItem
374
366
  icon={ upload }
375
- onClick={ () => {
376
- openFileDialog();
377
- } }
367
+ onClick={ openFileDialog }
378
368
  >
379
369
  { _x( 'Upload', 'verb' ) }
380
370
  </MenuItem>
@@ -1,5 +1,6 @@
1
1
  export default function Tracks( { tracks = [] } ) {
2
2
  return tracks.map( ( track ) => {
3
- return <track key={ track.src } { ...track } />;
3
+ const { id, ...trackAttrs } = track;
4
+ return <track key={ id ?? trackAttrs.src } { ...trackAttrs } />;
4
5
  } );
5
6
  }
@@ -1,81 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
- var _blockEditor = require("@wordpress/block-editor");
8
- var _components = require("@wordpress/components");
9
- var _i18n = require("@wordpress/i18n");
10
- var _element = require("@wordpress/element");
11
- var _jsxRuntime = require("react/jsx-runtime");
12
- /**
13
- * WordPress dependencies
14
- */
15
-
16
- function PosterImage({
17
- poster,
18
- setAttributes,
19
- instanceId
20
- }) {
21
- const posterImageButton = (0, _element.useRef)();
22
- const VIDEO_POSTER_ALLOWED_MEDIA_TYPES = ['image'];
23
- const videoPosterDescription = `video-block__poster-image-description-${instanceId}`;
24
- function onSelectPoster(image) {
25
- setAttributes({
26
- poster: image.url
27
- });
28
- }
29
- function onRemovePoster() {
30
- setAttributes({
31
- poster: undefined
32
- });
33
-
34
- // Move focus back to the Media Upload button.
35
- posterImageButton.current.focus();
36
- }
37
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.__experimentalToolsPanelItem, {
38
- label: (0, _i18n.__)('Poster image'),
39
- isShownByDefault: true,
40
- hasValue: () => !!poster,
41
- onDeselect: () => {
42
- setAttributes({
43
- poster: ''
44
- });
45
- },
46
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_blockEditor.MediaUploadCheck, {
47
- children: /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
48
- className: "editor-video-poster-control",
49
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_components.BaseControl.VisualLabel, {
50
- children: (0, _i18n.__)('Poster image')
51
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_blockEditor.MediaUpload, {
52
- title: (0, _i18n.__)('Select poster image'),
53
- onSelect: onSelectPoster,
54
- allowedTypes: VIDEO_POSTER_ALLOWED_MEDIA_TYPES,
55
- render: ({
56
- open
57
- }) => /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Button, {
58
- __next40pxDefaultSize: true,
59
- variant: "primary",
60
- onClick: open,
61
- ref: posterImageButton,
62
- "aria-describedby": videoPosterDescription,
63
- children: !poster ? (0, _i18n.__)('Select') : (0, _i18n.__)('Replace')
64
- })
65
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)("p", {
66
- id: videoPosterDescription,
67
- hidden: true,
68
- children: poster ? (0, _i18n.sprintf)(/* translators: %s: poster image URL. */
69
- (0, _i18n.__)('The current poster image url is %s'), poster) : (0, _i18n.__)('There is no poster image currently selected')
70
- }), !!poster && /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Button, {
71
- __next40pxDefaultSize: true,
72
- onClick: onRemovePoster,
73
- variant: "tertiary",
74
- children: (0, _i18n.__)('Remove')
75
- })]
76
- })
77
- })
78
- });
79
- }
80
- var _default = exports.default = PosterImage;
81
- //# sourceMappingURL=poster-image.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["_blockEditor","require","_components","_i18n","_element","_jsxRuntime","PosterImage","poster","setAttributes","instanceId","posterImageButton","useRef","VIDEO_POSTER_ALLOWED_MEDIA_TYPES","videoPosterDescription","onSelectPoster","image","url","onRemovePoster","undefined","current","focus","jsx","__experimentalToolsPanelItem","label","__","isShownByDefault","hasValue","onDeselect","children","MediaUploadCheck","jsxs","className","BaseControl","VisualLabel","MediaUpload","title","onSelect","allowedTypes","render","open","Button","__next40pxDefaultSize","variant","onClick","ref","id","hidden","sprintf","_default","exports","default"],"sources":["@wordpress/block-library/src/video/poster-image.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { MediaUpload, MediaUploadCheck } from '@wordpress/block-editor';\nimport {\n\tButton,\n\tBaseControl,\n\t__experimentalToolsPanelItem as ToolsPanelItem,\n} from '@wordpress/components';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { useRef } from '@wordpress/element';\n\nfunction PosterImage( { poster, setAttributes, instanceId } ) {\n\tconst posterImageButton = useRef();\n\tconst VIDEO_POSTER_ALLOWED_MEDIA_TYPES = [ 'image' ];\n\n\tconst videoPosterDescription = `video-block__poster-image-description-${ instanceId }`;\n\n\tfunction onSelectPoster( image ) {\n\t\tsetAttributes( { poster: image.url } );\n\t}\n\n\tfunction onRemovePoster() {\n\t\tsetAttributes( { poster: undefined } );\n\n\t\t// Move focus back to the Media Upload button.\n\t\tposterImageButton.current.focus();\n\t}\n\n\treturn (\n\t\t<ToolsPanelItem\n\t\t\tlabel={ __( 'Poster image' ) }\n\t\t\tisShownByDefault\n\t\t\thasValue={ () => !! poster }\n\t\t\tonDeselect={ () => {\n\t\t\t\tsetAttributes( { poster: '' } );\n\t\t\t} }\n\t\t>\n\t\t\t<MediaUploadCheck>\n\t\t\t\t<div className=\"editor-video-poster-control\">\n\t\t\t\t\t<BaseControl.VisualLabel>\n\t\t\t\t\t\t{ __( 'Poster image' ) }\n\t\t\t\t\t</BaseControl.VisualLabel>\n\t\t\t\t\t<MediaUpload\n\t\t\t\t\t\ttitle={ __( 'Select poster image' ) }\n\t\t\t\t\t\tonSelect={ onSelectPoster }\n\t\t\t\t\t\tallowedTypes={ VIDEO_POSTER_ALLOWED_MEDIA_TYPES }\n\t\t\t\t\t\trender={ ( { open } ) => (\n\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\t\t\t\tonClick={ open }\n\t\t\t\t\t\t\t\tref={ posterImageButton }\n\t\t\t\t\t\t\t\taria-describedby={ videoPosterDescription }\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ ! poster ? __( 'Select' ) : __( 'Replace' ) }\n\t\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t) }\n\t\t\t\t\t/>\n\t\t\t\t\t<p id={ videoPosterDescription } hidden>\n\t\t\t\t\t\t{ poster\n\t\t\t\t\t\t\t? sprintf(\n\t\t\t\t\t\t\t\t\t/* translators: %s: poster image URL. */\n\t\t\t\t\t\t\t\t\t__( 'The current poster image url is %s' ),\n\t\t\t\t\t\t\t\t\tposter\n\t\t\t\t\t\t\t )\n\t\t\t\t\t\t\t: __(\n\t\t\t\t\t\t\t\t\t'There is no poster image currently selected'\n\t\t\t\t\t\t\t ) }\n\t\t\t\t\t</p>\n\t\t\t\t\t{ !! poster && (\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\tonClick={ onRemovePoster }\n\t\t\t\t\t\t\tvariant=\"tertiary\"\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Remove' ) }\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t) }\n\t\t\t\t</div>\n\t\t\t</MediaUploadCheck>\n\t\t</ToolsPanelItem>\n\t);\n}\n\nexport default PosterImage;\n"],"mappings":"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","ignoreList":[]}
@@ -1,74 +0,0 @@
1
- /**
2
- * WordPress dependencies
3
- */
4
- import { MediaUpload, MediaUploadCheck } from '@wordpress/block-editor';
5
- import { Button, BaseControl, __experimentalToolsPanelItem as ToolsPanelItem } from '@wordpress/components';
6
- import { __, sprintf } from '@wordpress/i18n';
7
- import { useRef } from '@wordpress/element';
8
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
9
- function PosterImage({
10
- poster,
11
- setAttributes,
12
- instanceId
13
- }) {
14
- const posterImageButton = useRef();
15
- const VIDEO_POSTER_ALLOWED_MEDIA_TYPES = ['image'];
16
- const videoPosterDescription = `video-block__poster-image-description-${instanceId}`;
17
- function onSelectPoster(image) {
18
- setAttributes({
19
- poster: image.url
20
- });
21
- }
22
- function onRemovePoster() {
23
- setAttributes({
24
- poster: undefined
25
- });
26
-
27
- // Move focus back to the Media Upload button.
28
- posterImageButton.current.focus();
29
- }
30
- return /*#__PURE__*/_jsx(ToolsPanelItem, {
31
- label: __('Poster image'),
32
- isShownByDefault: true,
33
- hasValue: () => !!poster,
34
- onDeselect: () => {
35
- setAttributes({
36
- poster: ''
37
- });
38
- },
39
- children: /*#__PURE__*/_jsx(MediaUploadCheck, {
40
- children: /*#__PURE__*/_jsxs("div", {
41
- className: "editor-video-poster-control",
42
- children: [/*#__PURE__*/_jsx(BaseControl.VisualLabel, {
43
- children: __('Poster image')
44
- }), /*#__PURE__*/_jsx(MediaUpload, {
45
- title: __('Select poster image'),
46
- onSelect: onSelectPoster,
47
- allowedTypes: VIDEO_POSTER_ALLOWED_MEDIA_TYPES,
48
- render: ({
49
- open
50
- }) => /*#__PURE__*/_jsx(Button, {
51
- __next40pxDefaultSize: true,
52
- variant: "primary",
53
- onClick: open,
54
- ref: posterImageButton,
55
- "aria-describedby": videoPosterDescription,
56
- children: !poster ? __('Select') : __('Replace')
57
- })
58
- }), /*#__PURE__*/_jsx("p", {
59
- id: videoPosterDescription,
60
- hidden: true,
61
- children: poster ? sprintf(/* translators: %s: poster image URL. */
62
- __('The current poster image url is %s'), poster) : __('There is no poster image currently selected')
63
- }), !!poster && /*#__PURE__*/_jsx(Button, {
64
- __next40pxDefaultSize: true,
65
- onClick: onRemovePoster,
66
- variant: "tertiary",
67
- children: __('Remove')
68
- })]
69
- })
70
- })
71
- });
72
- }
73
- export default PosterImage;
74
- //# sourceMappingURL=poster-image.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["MediaUpload","MediaUploadCheck","Button","BaseControl","__experimentalToolsPanelItem","ToolsPanelItem","__","sprintf","useRef","jsx","_jsx","jsxs","_jsxs","PosterImage","poster","setAttributes","instanceId","posterImageButton","VIDEO_POSTER_ALLOWED_MEDIA_TYPES","videoPosterDescription","onSelectPoster","image","url","onRemovePoster","undefined","current","focus","label","isShownByDefault","hasValue","onDeselect","children","className","VisualLabel","title","onSelect","allowedTypes","render","open","__next40pxDefaultSize","variant","onClick","ref","id","hidden"],"sources":["@wordpress/block-library/src/video/poster-image.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { MediaUpload, MediaUploadCheck } from '@wordpress/block-editor';\nimport {\n\tButton,\n\tBaseControl,\n\t__experimentalToolsPanelItem as ToolsPanelItem,\n} from '@wordpress/components';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { useRef } from '@wordpress/element';\n\nfunction PosterImage( { poster, setAttributes, instanceId } ) {\n\tconst posterImageButton = useRef();\n\tconst VIDEO_POSTER_ALLOWED_MEDIA_TYPES = [ 'image' ];\n\n\tconst videoPosterDescription = `video-block__poster-image-description-${ instanceId }`;\n\n\tfunction onSelectPoster( image ) {\n\t\tsetAttributes( { poster: image.url } );\n\t}\n\n\tfunction onRemovePoster() {\n\t\tsetAttributes( { poster: undefined } );\n\n\t\t// Move focus back to the Media Upload button.\n\t\tposterImageButton.current.focus();\n\t}\n\n\treturn (\n\t\t<ToolsPanelItem\n\t\t\tlabel={ __( 'Poster image' ) }\n\t\t\tisShownByDefault\n\t\t\thasValue={ () => !! poster }\n\t\t\tonDeselect={ () => {\n\t\t\t\tsetAttributes( { poster: '' } );\n\t\t\t} }\n\t\t>\n\t\t\t<MediaUploadCheck>\n\t\t\t\t<div className=\"editor-video-poster-control\">\n\t\t\t\t\t<BaseControl.VisualLabel>\n\t\t\t\t\t\t{ __( 'Poster image' ) }\n\t\t\t\t\t</BaseControl.VisualLabel>\n\t\t\t\t\t<MediaUpload\n\t\t\t\t\t\ttitle={ __( 'Select poster image' ) }\n\t\t\t\t\t\tonSelect={ onSelectPoster }\n\t\t\t\t\t\tallowedTypes={ VIDEO_POSTER_ALLOWED_MEDIA_TYPES }\n\t\t\t\t\t\trender={ ( { open } ) => (\n\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\t\t\t\tonClick={ open }\n\t\t\t\t\t\t\t\tref={ posterImageButton }\n\t\t\t\t\t\t\t\taria-describedby={ videoPosterDescription }\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ ! poster ? __( 'Select' ) : __( 'Replace' ) }\n\t\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t) }\n\t\t\t\t\t/>\n\t\t\t\t\t<p id={ videoPosterDescription } hidden>\n\t\t\t\t\t\t{ poster\n\t\t\t\t\t\t\t? sprintf(\n\t\t\t\t\t\t\t\t\t/* translators: %s: poster image URL. */\n\t\t\t\t\t\t\t\t\t__( 'The current poster image url is %s' ),\n\t\t\t\t\t\t\t\t\tposter\n\t\t\t\t\t\t\t )\n\t\t\t\t\t\t\t: __(\n\t\t\t\t\t\t\t\t\t'There is no poster image currently selected'\n\t\t\t\t\t\t\t ) }\n\t\t\t\t\t</p>\n\t\t\t\t\t{ !! poster && (\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\tonClick={ onRemovePoster }\n\t\t\t\t\t\t\tvariant=\"tertiary\"\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Remove' ) }\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t) }\n\t\t\t\t</div>\n\t\t\t</MediaUploadCheck>\n\t\t</ToolsPanelItem>\n\t);\n}\n\nexport default PosterImage;\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,WAAW,EAAEC,gBAAgB,QAAQ,yBAAyB;AACvE,SACCC,MAAM,EACNC,WAAW,EACXC,4BAA4B,IAAIC,cAAc,QACxC,uBAAuB;AAC9B,SAASC,EAAE,EAAEC,OAAO,QAAQ,iBAAiB;AAC7C,SAASC,MAAM,QAAQ,oBAAoB;AAAC,SAAAC,GAAA,IAAAC,IAAA,EAAAC,IAAA,IAAAC,KAAA;AAE5C,SAASC,WAAWA,CAAE;EAAEC,MAAM;EAAEC,aAAa;EAAEC;AAAW,CAAC,EAAG;EAC7D,MAAMC,iBAAiB,GAAGT,MAAM,CAAC,CAAC;EAClC,MAAMU,gCAAgC,GAAG,CAAE,OAAO,CAAE;EAEpD,MAAMC,sBAAsB,GAAG,yCAA0CH,UAAU,EAAG;EAEtF,SAASI,cAAcA,CAAEC,KAAK,EAAG;IAChCN,aAAa,CAAE;MAAED,MAAM,EAAEO,KAAK,CAACC;IAAI,CAAE,CAAC;EACvC;EAEA,SAASC,cAAcA,CAAA,EAAG;IACzBR,aAAa,CAAE;MAAED,MAAM,EAAEU;IAAU,CAAE,CAAC;;IAEtC;IACAP,iBAAiB,CAACQ,OAAO,CAACC,KAAK,CAAC,CAAC;EAClC;EAEA,oBACChB,IAAA,CAACL,cAAc;IACdsB,KAAK,EAAGrB,EAAE,CAAE,cAAe,CAAG;IAC9BsB,gBAAgB;IAChBC,QAAQ,EAAGA,CAAA,KAAM,CAAC,CAAEf,MAAQ;IAC5BgB,UAAU,EAAGA,CAAA,KAAM;MAClBf,aAAa,CAAE;QAAED,MAAM,EAAE;MAAG,CAAE,CAAC;IAChC,CAAG;IAAAiB,QAAA,eAEHrB,IAAA,CAACT,gBAAgB;MAAA8B,QAAA,eAChBnB,KAAA;QAAKoB,SAAS,EAAC,6BAA6B;QAAAD,QAAA,gBAC3CrB,IAAA,CAACP,WAAW,CAAC8B,WAAW;UAAAF,QAAA,EACrBzB,EAAE,CAAE,cAAe;QAAC,CACE,CAAC,eAC1BI,IAAA,CAACV,WAAW;UACXkC,KAAK,EAAG5B,EAAE,CAAE,qBAAsB,CAAG;UACrC6B,QAAQ,EAAGf,cAAgB;UAC3BgB,YAAY,EAAGlB,gCAAkC;UACjDmB,MAAM,EAAGA,CAAE;YAAEC;UAAK,CAAC,kBAClB5B,IAAA,CAACR,MAAM;YACNqC,qBAAqB;YACrBC,OAAO,EAAC,SAAS;YACjBC,OAAO,EAAGH,IAAM;YAChBI,GAAG,EAAGzB,iBAAmB;YACzB,oBAAmBE,sBAAwB;YAAAY,QAAA,EAEzC,CAAEjB,MAAM,GAAGR,EAAE,CAAE,QAAS,CAAC,GAAGA,EAAE,CAAE,SAAU;UAAC,CACtC;QACN,CACH,CAAC,eACFI,IAAA;UAAGiC,EAAE,EAAGxB,sBAAwB;UAACyB,MAAM;UAAAb,QAAA,EACpCjB,MAAM,GACLP,OAAO,CACP;UACAD,EAAE,CAAE,oCAAqC,CAAC,EAC1CQ,MACA,CAAC,GACDR,EAAE,CACF,6CACA;QAAC,CACF,CAAC,EACF,CAAC,CAAEQ,MAAM,iBACVJ,IAAA,CAACR,MAAM;UACNqC,qBAAqB;UACrBE,OAAO,EAAGlB,cAAgB;UAC1BiB,OAAO,EAAC,UAAU;UAAAT,QAAA,EAEhBzB,EAAE,CAAE,QAAS;QAAC,CACT,CACR;MAAA,CACG;IAAC,CACW;EAAC,CACJ,CAAC;AAEnB;AAEA,eAAeO,WAAW","ignoreList":[]}
@@ -1,86 +0,0 @@
1
- /**
2
- * WordPress dependencies
3
- */
4
- import { MediaUpload, MediaUploadCheck } from '@wordpress/block-editor';
5
- import {
6
- Button,
7
- BaseControl,
8
- __experimentalToolsPanelItem as ToolsPanelItem,
9
- } from '@wordpress/components';
10
- import { __, sprintf } from '@wordpress/i18n';
11
- import { useRef } from '@wordpress/element';
12
-
13
- function PosterImage( { poster, setAttributes, instanceId } ) {
14
- const posterImageButton = useRef();
15
- const VIDEO_POSTER_ALLOWED_MEDIA_TYPES = [ 'image' ];
16
-
17
- const videoPosterDescription = `video-block__poster-image-description-${ instanceId }`;
18
-
19
- function onSelectPoster( image ) {
20
- setAttributes( { poster: image.url } );
21
- }
22
-
23
- function onRemovePoster() {
24
- setAttributes( { poster: undefined } );
25
-
26
- // Move focus back to the Media Upload button.
27
- posterImageButton.current.focus();
28
- }
29
-
30
- return (
31
- <ToolsPanelItem
32
- label={ __( 'Poster image' ) }
33
- isShownByDefault
34
- hasValue={ () => !! poster }
35
- onDeselect={ () => {
36
- setAttributes( { poster: '' } );
37
- } }
38
- >
39
- <MediaUploadCheck>
40
- <div className="editor-video-poster-control">
41
- <BaseControl.VisualLabel>
42
- { __( 'Poster image' ) }
43
- </BaseControl.VisualLabel>
44
- <MediaUpload
45
- title={ __( 'Select poster image' ) }
46
- onSelect={ onSelectPoster }
47
- allowedTypes={ VIDEO_POSTER_ALLOWED_MEDIA_TYPES }
48
- render={ ( { open } ) => (
49
- <Button
50
- __next40pxDefaultSize
51
- variant="primary"
52
- onClick={ open }
53
- ref={ posterImageButton }
54
- aria-describedby={ videoPosterDescription }
55
- >
56
- { ! poster ? __( 'Select' ) : __( 'Replace' ) }
57
- </Button>
58
- ) }
59
- />
60
- <p id={ videoPosterDescription } hidden>
61
- { poster
62
- ? sprintf(
63
- /* translators: %s: poster image URL. */
64
- __( 'The current poster image url is %s' ),
65
- poster
66
- )
67
- : __(
68
- 'There is no poster image currently selected'
69
- ) }
70
- </p>
71
- { !! poster && (
72
- <Button
73
- __next40pxDefaultSize
74
- onClick={ onRemovePoster }
75
- variant="tertiary"
76
- >
77
- { __( 'Remove' ) }
78
- </Button>
79
- ) }
80
- </div>
81
- </MediaUploadCheck>
82
- </ToolsPanelItem>
83
- );
84
- }
85
-
86
- export default PosterImage;