@wordpress/block-library 9.27.0 → 9.28.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 (185) 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/index.js +1 -1
  5. package/build/cover/edit/index.js.map +1 -1
  6. package/build/cover/edit/inspector-controls.js +5 -3
  7. package/build/cover/edit/inspector-controls.js.map +1 -1
  8. package/build/file/edit.js +5 -2
  9. package/build/file/edit.js.map +1 -1
  10. package/build/file/edit.native.js +1 -1
  11. package/build/file/edit.native.js.map +1 -1
  12. package/build/file/transforms.js +6 -6
  13. package/build/file/transforms.js.map +1 -1
  14. package/build/file/utils/index.js +5 -0
  15. package/build/file/utils/index.js.map +1 -1
  16. package/build/gallery/use-get-media.js +3 -3
  17. package/build/gallery/use-get-media.js.map +1 -1
  18. package/build/gallery/use-get-media.native.js +3 -3
  19. package/build/gallery/use-get-media.native.js.map +1 -1
  20. package/build/image/edit.native.js +2 -2
  21. package/build/image/edit.native.js.map +1 -1
  22. package/build/image/image.js +1 -1
  23. package/build/image/image.js.map +1 -1
  24. package/build/latest-posts/edit.js +0 -2
  25. package/build/latest-posts/edit.js.map +1 -1
  26. package/build/list-item/edit.js +3 -0
  27. package/build/list-item/edit.js.map +1 -1
  28. package/build/media-text/edit.js +2 -2
  29. package/build/media-text/edit.js.map +1 -1
  30. package/build/more/edit.js +13 -28
  31. package/build/more/edit.js.map +1 -1
  32. package/build/paragraph/edit.js +2 -2
  33. package/build/paragraph/edit.js.map +1 -1
  34. package/build/post-comments-count/index.js +3 -0
  35. package/build/post-comments-count/index.js.map +1 -1
  36. package/build/post-comments-link/index.js +3 -0
  37. package/build/post-comments-link/index.js.map +1 -1
  38. package/build/post-date/deprecated.js +104 -1
  39. package/build/post-date/deprecated.js.map +1 -1
  40. package/build/post-date/edit.js +32 -32
  41. package/build/post-date/edit.js.map +1 -1
  42. package/build/post-date/index.js +4 -4
  43. package/build/post-date/index.js.map +1 -1
  44. package/build/post-date/variations.js +32 -3
  45. package/build/post-date/variations.js.map +1 -1
  46. package/build/post-featured-image/edit.js +2 -2
  47. package/build/post-featured-image/edit.js.map +1 -1
  48. package/build/site-logo/edit.js +2 -2
  49. package/build/site-logo/edit.js.map +1 -1
  50. package/build/social-link/icons/tiktok.js +2 -2
  51. package/build/social-link/icons/tiktok.js.map +1 -1
  52. package/build/social-link/variations.js +51 -49
  53. package/build/social-link/variations.js.map +1 -1
  54. package/build/utils/poster-image.js +141 -0
  55. package/build/utils/poster-image.js.map +1 -0
  56. package/build/video/edit.js +6 -2
  57. package/build/video/edit.js.map +1 -1
  58. package/build-module/categories/edit.js +15 -3
  59. package/build-module/categories/edit.js.map +1 -1
  60. package/build-module/cover/edit/index.js +1 -1
  61. package/build-module/cover/edit/index.js.map +1 -1
  62. package/build-module/cover/edit/inspector-controls.js +5 -3
  63. package/build-module/cover/edit/inspector-controls.js.map +1 -1
  64. package/build-module/file/edit.js +5 -2
  65. package/build-module/file/edit.js.map +1 -1
  66. package/build-module/file/edit.native.js +1 -1
  67. package/build-module/file/edit.native.js.map +1 -1
  68. package/build-module/file/transforms.js +6 -6
  69. package/build-module/file/transforms.js.map +1 -1
  70. package/build-module/file/utils/index.js +5 -0
  71. package/build-module/file/utils/index.js.map +1 -1
  72. package/build-module/gallery/use-get-media.js +3 -3
  73. package/build-module/gallery/use-get-media.js.map +1 -1
  74. package/build-module/gallery/use-get-media.native.js +3 -3
  75. package/build-module/gallery/use-get-media.native.js.map +1 -1
  76. package/build-module/image/edit.native.js +2 -2
  77. package/build-module/image/edit.native.js.map +1 -1
  78. package/build-module/image/image.js +1 -1
  79. package/build-module/image/image.js.map +1 -1
  80. package/build-module/latest-posts/edit.js +0 -2
  81. package/build-module/latest-posts/edit.js.map +1 -1
  82. package/build-module/list-item/edit.js +3 -0
  83. package/build-module/list-item/edit.js.map +1 -1
  84. package/build-module/media-text/edit.js +2 -2
  85. package/build-module/media-text/edit.js.map +1 -1
  86. package/build-module/more/edit.js +15 -29
  87. package/build-module/more/edit.js.map +1 -1
  88. package/build-module/paragraph/edit.js +2 -2
  89. package/build-module/paragraph/edit.js.map +1 -1
  90. package/build-module/post-comments-count/index.js +3 -0
  91. package/build-module/post-comments-count/index.js.map +1 -1
  92. package/build-module/post-comments-link/index.js +3 -0
  93. package/build-module/post-comments-link/index.js.map +1 -1
  94. package/build-module/post-date/deprecated.js +104 -1
  95. package/build-module/post-date/deprecated.js.map +1 -1
  96. package/build-module/post-date/edit.js +35 -35
  97. package/build-module/post-date/edit.js.map +1 -1
  98. package/build-module/post-date/index.js +4 -4
  99. package/build-module/post-date/index.js.map +1 -1
  100. package/build-module/post-date/variations.js +32 -3
  101. package/build-module/post-date/variations.js.map +1 -1
  102. package/build-module/post-featured-image/edit.js +2 -2
  103. package/build-module/post-featured-image/edit.js.map +1 -1
  104. package/build-module/site-logo/edit.js +2 -2
  105. package/build-module/site-logo/edit.js.map +1 -1
  106. package/build-module/social-link/icons/tiktok.js +2 -2
  107. package/build-module/social-link/icons/tiktok.js.map +1 -1
  108. package/build-module/social-link/variations.js +52 -50
  109. package/build-module/social-link/variations.js.map +1 -1
  110. package/build-module/utils/poster-image.js +133 -0
  111. package/build-module/utils/poster-image.js.map +1 -0
  112. package/build-module/video/edit.js +6 -2
  113. package/build-module/video/edit.js.map +1 -1
  114. package/build-style/editor-rtl.css +77 -23
  115. package/build-style/editor.css +77 -23
  116. package/build-style/gallery/style-rtl.css +1 -2
  117. package/build-style/gallery/style.css +1 -2
  118. package/build-style/image/style-rtl.css +1 -2
  119. package/build-style/image/style.css +1 -2
  120. package/build-style/more/editor-rtl.css +3 -11
  121. package/build-style/more/editor.css +3 -11
  122. package/build-style/navigation/editor-rtl.css +6 -6
  123. package/build-style/navigation/editor.css +6 -6
  124. package/build-style/page-list/editor-rtl.css +0 -4
  125. package/build-style/page-list/editor.css +0 -4
  126. package/build-style/post-featured-image/editor-rtl.css +1 -2
  127. package/build-style/post-featured-image/editor.css +1 -2
  128. package/build-style/style-rtl.css +3 -4
  129. package/build-style/style.css +3 -4
  130. package/build-style/video/style-rtl.css +1 -0
  131. package/build-style/video/style.css +1 -0
  132. package/package.json +35 -35
  133. package/src/block/index.php +33 -20
  134. package/src/categories/edit.js +13 -1
  135. package/src/cover/edit/index.js +8 -3
  136. package/src/cover/edit/inspector-controls.js +12 -3
  137. package/src/editor.scss +1 -0
  138. package/src/file/edit.js +10 -2
  139. package/src/file/edit.native.js +5 -1
  140. package/src/file/transforms.js +6 -6
  141. package/src/file/utils/index.js +5 -0
  142. package/src/form-input/index.php +4 -2
  143. package/src/gallery/use-get-media.js +9 -5
  144. package/src/gallery/use-get-media.native.js +10 -6
  145. package/src/image/edit.native.js +4 -2
  146. package/src/image/image.js +6 -1
  147. package/src/image/index.php +1 -1
  148. package/src/image/test/edit.native.js +16 -10
  149. package/src/latest-posts/edit.js +0 -2
  150. package/src/list-item/edit.js +3 -0
  151. package/src/loginout/index.php +4 -2
  152. package/src/media-text/edit.js +16 -6
  153. package/src/more/edit.js +27 -33
  154. package/src/more/editor.scss +3 -12
  155. package/src/page-list/editor.scss +0 -6
  156. package/src/paragraph/edit.js +2 -2
  157. package/src/post-comments-count/block.json +3 -0
  158. package/src/post-comments-link/block.json +3 -0
  159. package/src/post-date/block.json +4 -4
  160. package/src/post-date/deprecated.js +104 -1
  161. package/src/post-date/edit.js +74 -86
  162. package/src/post-date/index.php +51 -28
  163. package/src/post-date/variations.js +37 -3
  164. package/src/post-featured-image/edit.js +2 -2
  165. package/src/site-logo/edit.js +11 -4
  166. package/src/social-link/README.md +21 -0
  167. package/src/social-link/icons/tiktok.js +2 -2
  168. package/src/social-link/index.php +49 -49
  169. package/src/social-link/variations.js +51 -49
  170. package/src/utils/poster-image.js +176 -0
  171. package/src/utils/poster-image.scss +82 -0
  172. package/src/video/edit.js +7 -2
  173. package/src/video/index.php +91 -0
  174. package/src/video/style.native.scss +1 -0
  175. package/src/video/style.scss +1 -0
  176. package/build/cover/edit/poster-image.js +0 -81
  177. package/build/cover/edit/poster-image.js.map +0 -1
  178. package/build/video/poster-image.js +0 -81
  179. package/build/video/poster-image.js.map +0 -1
  180. package/build-module/cover/edit/poster-image.js +0 -74
  181. package/build-module/cover/edit/poster-image.js.map +0 -1
  182. package/build-module/video/poster-image.js +0 -74
  183. package/build-module/video/poster-image.js.map +0 -1
  184. package/src/cover/edit/poster-image.js +0 -91
  185. package/src/video/poster-image.js +0 -91
@@ -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
 
@@ -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 _compose = require("@wordpress/compose");
12
- var _jsxRuntime = require("react/jsx-runtime");
13
- /**
14
- * WordPress dependencies
15
- */
16
-
17
- const COVER_POSTER_ALLOWED_MEDIA_TYPES = ['image'];
18
- function PosterImage({
19
- poster,
20
- setAttributes
21
- }) {
22
- const posterButtonRef = (0, _element.useRef)();
23
- const descriptionId = (0, _compose.useInstanceId)(PosterImage, 'cover-block__poster-image-description');
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
- posterButtonRef.current.focus();
36
- }
37
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(_blockEditor.MediaUploadCheck, {
38
- children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_components.__experimentalToolsPanelItem, {
39
- label: (0, _i18n.__)('Poster image'),
40
- isShownByDefault: true,
41
- hasValue: () => !!poster,
42
- onDeselect: () => {
43
- setAttributes({
44
- poster: undefined
45
- });
46
- },
47
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_components.BaseControl.VisualLabel, {
48
- children: (0, _i18n.__)('Poster image')
49
- }), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_components.__experimentalHStack, {
50
- justify: "flex-start",
51
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_blockEditor.MediaUpload, {
52
- title: (0, _i18n.__)('Select poster image'),
53
- onSelect: onSelectPoster,
54
- allowedTypes: COVER_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: posterButtonRef,
62
- "aria-describedby": descriptionId,
63
- children: !poster ? (0, _i18n.__)('Select') : (0, _i18n.__)('Replace')
64
- })
65
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)("p", {
66
- id: descriptionId,
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","_compose","_jsxRuntime","COVER_POSTER_ALLOWED_MEDIA_TYPES","PosterImage","poster","setAttributes","posterButtonRef","useRef","descriptionId","useInstanceId","onSelectPoster","image","url","onRemovePoster","undefined","current","focus","jsx","MediaUploadCheck","children","jsxs","__experimentalToolsPanelItem","label","__","isShownByDefault","hasValue","onDeselect","BaseControl","VisualLabel","__experimentalHStack","justify","MediaUpload","title","onSelect","allowedTypes","render","open","Button","__next40pxDefaultSize","variant","onClick","ref","id","hidden","sprintf","_default","exports","default"],"sources":["@wordpress/block-library/src/cover/edit/poster-image.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { MediaUpload, MediaUploadCheck } from '@wordpress/block-editor';\nimport {\n\tButton,\n\tBaseControl,\n\t__experimentalHStack as HStack,\n\t__experimentalToolsPanelItem as ToolsPanelItem,\n} from '@wordpress/components';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { useRef } from '@wordpress/element';\nimport { useInstanceId } from '@wordpress/compose';\n\nconst COVER_POSTER_ALLOWED_MEDIA_TYPES = [ 'image' ];\n\nfunction PosterImage( { poster, setAttributes } ) {\n\tconst posterButtonRef = useRef();\n\tconst descriptionId = useInstanceId(\n\t\tPosterImage,\n\t\t'cover-block__poster-image-description'\n\t);\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\tposterButtonRef.current.focus();\n\t}\n\n\treturn (\n\t\t<MediaUploadCheck>\n\t\t\t<ToolsPanelItem\n\t\t\t\tlabel={ __( 'Poster image' ) }\n\t\t\t\tisShownByDefault\n\t\t\t\thasValue={ () => !! poster }\n\t\t\t\tonDeselect={ () => {\n\t\t\t\t\tsetAttributes( { poster: undefined } );\n\t\t\t\t} }\n\t\t\t>\n\t\t\t\t<BaseControl.VisualLabel>\n\t\t\t\t\t{ __( 'Poster image' ) }\n\t\t\t\t</BaseControl.VisualLabel>\n\t\t\t\t<HStack justify=\"flex-start\">\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={ COVER_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={ posterButtonRef }\n\t\t\t\t\t\t\t\taria-describedby={ descriptionId }\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={ descriptionId } 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</HStack>\n\t\t\t</ToolsPanelItem>\n\t\t</MediaUploadCheck>\n\t);\n}\n\nexport default PosterImage;\n"],"mappings":";;;;;;AAGA,IAAAA,YAAA,GAAAC,OAAA;AACA,IAAAC,WAAA,GAAAD,OAAA;AAMA,IAAAE,KAAA,GAAAF,OAAA;AACA,IAAAG,QAAA,GAAAH,OAAA;AACA,IAAAI,QAAA,GAAAJ,OAAA;AAAmD,IAAAK,WAAA,GAAAL,OAAA;AAZnD;AACA;AACA;;AAYA,MAAMM,gCAAgC,GAAG,CAAE,OAAO,CAAE;AAEpD,SAASC,WAAWA,CAAE;EAAEC,MAAM;EAAEC;AAAc,CAAC,EAAG;EACjD,MAAMC,eAAe,GAAG,IAAAC,eAAM,EAAC,CAAC;EAChC,MAAMC,aAAa,GAAG,IAAAC,sBAAa,EAClCN,WAAW,EACX,uCACD,CAAC;EAED,SAASO,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;IACAR,eAAe,CAACS,OAAO,CAACC,KAAK,CAAC,CAAC;EAChC;EAEA,oBACC,IAAAf,WAAA,CAAAgB,GAAA,EAACtB,YAAA,CAAAuB,gBAAgB;IAAAC,QAA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AAE,qCAAsC,CAAC,EAC3CnB,MACA,CAAC,GACD,IAAAmB,QAAE,EACF,8CACA;QAAC,CACF,CAAC,EACF,CAAC,CAAEnB,MAAM,iBACV,IAAAH,WAAA,CAAAgB,GAAA,EAACpB,WAAA,CAAAwC,MAAM;UACNC,qBAAqB;UACrBE,OAAO,EAAG3B,cAAgB;UAC1B0B,OAAO,EAAC,UAAU;UAAApB,QAAA,EAEhB,IAAAI,QAAE,EAAE,QAAS;QAAC,CACT,CACR;MAAA,CACM,CAAC;IAAA,CACM;EAAC,CACA,CAAC;AAErB;AAAC,IAAAsB,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEc5C,WAAW","ignoreList":[]}
@@ -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 _compose = require("@wordpress/compose");
12
- var _jsxRuntime = require("react/jsx-runtime");
13
- /**
14
- * WordPress dependencies
15
- */
16
-
17
- const VIDEO_POSTER_ALLOWED_MEDIA_TYPES = ['image'];
18
- function PosterImage({
19
- poster,
20
- setAttributes
21
- }) {
22
- const posterButtonRef = (0, _element.useRef)();
23
- const descriptionId = (0, _compose.useInstanceId)(PosterImage, 'video-block__poster-image-description');
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
- posterButtonRef.current.focus();
36
- }
37
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(_blockEditor.MediaUploadCheck, {
38
- children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_components.__experimentalToolsPanelItem, {
39
- label: (0, _i18n.__)('Poster image'),
40
- isShownByDefault: true,
41
- hasValue: () => !!poster,
42
- onDeselect: () => {
43
- setAttributes({
44
- poster: undefined
45
- });
46
- },
47
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_components.BaseControl.VisualLabel, {
48
- children: (0, _i18n.__)('Poster image')
49
- }), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_components.__experimentalHStack, {
50
- justify: "flex-start",
51
- children: [/*#__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: posterButtonRef,
62
- "aria-describedby": descriptionId,
63
- children: !poster ? (0, _i18n.__)('Select') : (0, _i18n.__)('Replace')
64
- })
65
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)("p", {
66
- id: descriptionId,
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","_compose","_jsxRuntime","VIDEO_POSTER_ALLOWED_MEDIA_TYPES","PosterImage","poster","setAttributes","posterButtonRef","useRef","descriptionId","useInstanceId","onSelectPoster","image","url","onRemovePoster","undefined","current","focus","jsx","MediaUploadCheck","children","jsxs","__experimentalToolsPanelItem","label","__","isShownByDefault","hasValue","onDeselect","BaseControl","VisualLabel","__experimentalHStack","justify","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__experimentalHStack as HStack,\n\t__experimentalToolsPanelItem as ToolsPanelItem,\n} from '@wordpress/components';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { useRef } from '@wordpress/element';\nimport { useInstanceId } from '@wordpress/compose';\n\nconst VIDEO_POSTER_ALLOWED_MEDIA_TYPES = [ 'image' ];\n\nfunction PosterImage( { poster, setAttributes } ) {\n\tconst posterButtonRef = useRef();\n\tconst descriptionId = useInstanceId(\n\t\tPosterImage,\n\t\t'video-block__poster-image-description'\n\t);\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\tposterButtonRef.current.focus();\n\t}\n\n\treturn (\n\t\t<MediaUploadCheck>\n\t\t\t<ToolsPanelItem\n\t\t\t\tlabel={ __( 'Poster image' ) }\n\t\t\t\tisShownByDefault\n\t\t\t\thasValue={ () => !! poster }\n\t\t\t\tonDeselect={ () => {\n\t\t\t\t\tsetAttributes( { poster: undefined } );\n\t\t\t\t} }\n\t\t\t>\n\t\t\t\t<BaseControl.VisualLabel>\n\t\t\t\t\t{ __( 'Poster image' ) }\n\t\t\t\t</BaseControl.VisualLabel>\n\t\t\t\t<HStack justify=\"flex-start\">\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={ posterButtonRef }\n\t\t\t\t\t\t\t\taria-describedby={ descriptionId }\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={ descriptionId } 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</HStack>\n\t\t\t</ToolsPanelItem>\n\t\t</MediaUploadCheck>\n\t);\n}\n\nexport default PosterImage;\n"],"mappings":";;;;;;AAGA,IAAAA,YAAA,GAAAC,OAAA;AACA,IAAAC,WAAA,GAAAD,OAAA;AAMA,IAAAE,KAAA,GAAAF,OAAA;AACA,IAAAG,QAAA,GAAAH,OAAA;AACA,IAAAI,QAAA,GAAAJ,OAAA;AAAmD,IAAAK,WAAA,GAAAL,OAAA;AAZnD;AACA;AACA;;AAYA,MAAMM,gCAAgC,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vB,cAAgB;UAC3BwB,YAAY,EAAGhC,gCAAkC;UACjDiC,MAAM,EAAGA,CAAE;YAAEC;UAAK,CAAC,kBAClB,IAAAnC,WAAA,CAAAgB,GAAA,EAACpB,WAAA,CAAAwC,MAAM;YACNC,qBAAqB;YACrBC,OAAO,EAAC,SAAS;YACjBC,OAAO,EAAGJ,IAAM;YAChBK,GAAG,EAAGnC,eAAiB;YACvB,oBAAmBE,aAAe;YAAAW,QAAA,EAEhC,CAAEf,MAAM,GAAG,IAAAmB,QAAE,EAAE,QAAS,CAAC,GAAG,IAAAA,QAAE,EAAE,SAAU;UAAC,CACtC;QACN,CACH,CAAC,eACF,IAAAtB,WAAA,CAAAgB,GAAA;UAAGyB,EAAE,EAAGlC,aAAe;UAACmC,MAAM;UAAAxB,QAAA,EAC3Bf,MAAM,GACL,IAAAwC,aAAO,EACP;UACA,IAAArB,QAAE,EAAE,oCAAqC,CAAC,EAC1CnB,MACA,CAAC,GACD,IAAAmB,QAAE,EACF,6CACA;QAAC,CACF,CAAC,EACF,CAAC,CAAEnB,MAAM,iBACV,IAAAH,WAAA,CAAAgB,GAAA,EAACpB,WAAA,CAAAwC,MAAM;UACNC,qBAAqB;UACrBE,OAAO,EAAG3B,cAAgB;UAC1B0B,OAAO,EAAC,UAAU;UAAApB,QAAA,EAEhB,IAAAI,QAAE,EAAE,QAAS;QAAC,CACT,CACR;MAAA,CACM,CAAC;IAAA,CACM;EAAC,CACA,CAAC;AAErB;AAAC,IAAAsB,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEc5C,WAAW","ignoreList":[]}
@@ -1,74 +0,0 @@
1
- /**
2
- * WordPress dependencies
3
- */
4
- import { MediaUpload, MediaUploadCheck } from '@wordpress/block-editor';
5
- import { Button, BaseControl, __experimentalHStack as HStack, __experimentalToolsPanelItem as ToolsPanelItem } from '@wordpress/components';
6
- import { __, sprintf } from '@wordpress/i18n';
7
- import { useRef } from '@wordpress/element';
8
- import { useInstanceId } from '@wordpress/compose';
9
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
10
- const COVER_POSTER_ALLOWED_MEDIA_TYPES = ['image'];
11
- function PosterImage({
12
- poster,
13
- setAttributes
14
- }) {
15
- const posterButtonRef = useRef();
16
- const descriptionId = useInstanceId(PosterImage, 'cover-block__poster-image-description');
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
- posterButtonRef.current.focus();
29
- }
30
- return /*#__PURE__*/_jsx(MediaUploadCheck, {
31
- children: /*#__PURE__*/_jsxs(ToolsPanelItem, {
32
- label: __('Poster image'),
33
- isShownByDefault: true,
34
- hasValue: () => !!poster,
35
- onDeselect: () => {
36
- setAttributes({
37
- poster: undefined
38
- });
39
- },
40
- children: [/*#__PURE__*/_jsx(BaseControl.VisualLabel, {
41
- children: __('Poster image')
42
- }), /*#__PURE__*/_jsxs(HStack, {
43
- justify: "flex-start",
44
- children: [/*#__PURE__*/_jsx(MediaUpload, {
45
- title: __('Select poster image'),
46
- onSelect: onSelectPoster,
47
- allowedTypes: COVER_POSTER_ALLOWED_MEDIA_TYPES,
48
- render: ({
49
- open
50
- }) => /*#__PURE__*/_jsx(Button, {
51
- __next40pxDefaultSize: true,
52
- variant: "primary",
53
- onClick: open,
54
- ref: posterButtonRef,
55
- "aria-describedby": descriptionId,
56
- children: !poster ? __('Select') : __('Replace')
57
- })
58
- }), /*#__PURE__*/_jsx("p", {
59
- id: descriptionId,
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","__experimentalHStack","HStack","__experimentalToolsPanelItem","ToolsPanelItem","__","sprintf","useRef","useInstanceId","jsx","_jsx","jsxs","_jsxs","COVER_POSTER_ALLOWED_MEDIA_TYPES","PosterImage","poster","setAttributes","posterButtonRef","descriptionId","onSelectPoster","image","url","onRemovePoster","undefined","current","focus","children","label","isShownByDefault","hasValue","onDeselect","VisualLabel","justify","title","onSelect","allowedTypes","render","open","__next40pxDefaultSize","variant","onClick","ref","id","hidden"],"sources":["@wordpress/block-library/src/cover/edit/poster-image.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { MediaUpload, MediaUploadCheck } from '@wordpress/block-editor';\nimport {\n\tButton,\n\tBaseControl,\n\t__experimentalHStack as HStack,\n\t__experimentalToolsPanelItem as ToolsPanelItem,\n} from '@wordpress/components';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { useRef } from '@wordpress/element';\nimport { useInstanceId } from '@wordpress/compose';\n\nconst COVER_POSTER_ALLOWED_MEDIA_TYPES = [ 'image' ];\n\nfunction PosterImage( { poster, setAttributes } ) {\n\tconst posterButtonRef = useRef();\n\tconst descriptionId = useInstanceId(\n\t\tPosterImage,\n\t\t'cover-block__poster-image-description'\n\t);\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\tposterButtonRef.current.focus();\n\t}\n\n\treturn (\n\t\t<MediaUploadCheck>\n\t\t\t<ToolsPanelItem\n\t\t\t\tlabel={ __( 'Poster image' ) }\n\t\t\t\tisShownByDefault\n\t\t\t\thasValue={ () => !! poster }\n\t\t\t\tonDeselect={ () => {\n\t\t\t\t\tsetAttributes( { poster: undefined } );\n\t\t\t\t} }\n\t\t\t>\n\t\t\t\t<BaseControl.VisualLabel>\n\t\t\t\t\t{ __( 'Poster image' ) }\n\t\t\t\t</BaseControl.VisualLabel>\n\t\t\t\t<HStack justify=\"flex-start\">\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={ COVER_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={ posterButtonRef }\n\t\t\t\t\t\t\t\taria-describedby={ descriptionId }\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={ descriptionId } 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</HStack>\n\t\t\t</ToolsPanelItem>\n\t\t</MediaUploadCheck>\n\t);\n}\n\nex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cAAe;MAAC,CACE,CAAC,eAC1BO,KAAA,CAACV,MAAM;QAAC8B,OAAO,EAAC,YAAY;QAAAN,QAAA,gBAC3BhB,IAAA,CAACb,WAAW;UACXoC,KAAK,EAAG5B,EAAE,CAAE,qBAAsB,CAAG;UACrC6B,QAAQ,EAAGf,cAAgB;UAC3BgB,YAAY,EAAGtB,gCAAkC;UACjDuB,MAAM,EAAGA,CAAE;YAAEC;UAAK,CAAC,kBAClB3B,IAAA,CAACX,MAAM;YACNuC,qBAAqB;YACrBC,OAAO,EAAC,SAAS;YACjBC,OAAO,EAAGH,IAAM;YAChBI,GAAG,EAAGxB,eAAiB;YACvB,oBAAmBC,aAAe;YAAAQ,QAAA,EAEhC,CAAEX,MAAM,GAAGV,EAAE,CAAE,QAAS,CAAC,GAAGA,EAAE,CAAE,SAAU;UAAC,CACtC;QACN,CACH,CAAC,eACFK,IAAA;UAAGgC,EAAE,EAAGxB,aAAe;UAACyB,MAAM;UAAAjB,QAAA,EAC3BX,MAAM,GACLT,OAAO,CACP;UACAD,EAAE,CAAE,qCAAsC,CAAC,EAC3CU,MACA,CAAC,GACDV,EAAE,CACF,8CACA;QAAC,CACF,CAAC,EACF,CAAC,CAAEU,MAAM,iBACVL,IAAA,CAACX,MAAM;UACNuC,qBAAqB;UACrBE,OAAO,EAAGlB,cAAgB;UAC1BiB,OAAO,EAAC,UAAU;UAAAb,QAAA,EAEhBrB,EAAE,CAAE,QAAS;QAAC,CACT,CACR;MAAA,CACM,CAAC;IAAA,CACM;EAAC,CACA,CAAC;AAErB;AAEA,eAAeS,WAAW","ignoreList":[]}
@@ -1,74 +0,0 @@
1
- /**
2
- * WordPress dependencies
3
- */
4
- import { MediaUpload, MediaUploadCheck } from '@wordpress/block-editor';
5
- import { Button, BaseControl, __experimentalHStack as HStack, __experimentalToolsPanelItem as ToolsPanelItem } from '@wordpress/components';
6
- import { __, sprintf } from '@wordpress/i18n';
7
- import { useRef } from '@wordpress/element';
8
- import { useInstanceId } from '@wordpress/compose';
9
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
10
- const VIDEO_POSTER_ALLOWED_MEDIA_TYPES = ['image'];
11
- function PosterImage({
12
- poster,
13
- setAttributes
14
- }) {
15
- const posterButtonRef = useRef();
16
- const descriptionId = useInstanceId(PosterImage, 'video-block__poster-image-description');
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
- posterButtonRef.current.focus();
29
- }
30
- return /*#__PURE__*/_jsx(MediaUploadCheck, {
31
- children: /*#__PURE__*/_jsxs(ToolsPanelItem, {
32
- label: __('Poster image'),
33
- isShownByDefault: true,
34
- hasValue: () => !!poster,
35
- onDeselect: () => {
36
- setAttributes({
37
- poster: undefined
38
- });
39
- },
40
- children: [/*#__PURE__*/_jsx(BaseControl.VisualLabel, {
41
- children: __('Poster image')
42
- }), /*#__PURE__*/_jsxs(HStack, {
43
- justify: "flex-start",
44
- children: [/*#__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: posterButtonRef,
55
- "aria-describedby": descriptionId,
56
- children: !poster ? __('Select') : __('Replace')
57
- })
58
- }), /*#__PURE__*/_jsx("p", {
59
- id: descriptionId,
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","__experimentalHStack","HStack","__experimentalToolsPanelItem","ToolsPanelItem","__","sprintf","useRef","useInstanceId","jsx","_jsx","jsxs","_jsxs","VIDEO_POSTER_ALLOWED_MEDIA_TYPES","PosterImage","poster","setAttributes","posterButtonRef","descriptionId","onSelectPoster","image","url","onRemovePoster","undefined","current","focus","children","label","isShownByDefault","hasValue","onDeselect","VisualLabel","justify","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__experimentalHStack as HStack,\n\t__experimentalToolsPanelItem as ToolsPanelItem,\n} from '@wordpress/components';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { useRef } from '@wordpress/element';\nimport { useInstanceId } from '@wordpress/compose';\n\nconst VIDEO_POSTER_ALLOWED_MEDIA_TYPES = [ 'image' ];\n\nfunction PosterImage( { poster, setAttributes } ) {\n\tconst posterButtonRef = useRef();\n\tconst descriptionId = useInstanceId(\n\t\tPosterImage,\n\t\t'video-block__poster-image-description'\n\t);\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\tposterButtonRef.current.focus();\n\t}\n\n\treturn (\n\t\t<MediaUploadCheck>\n\t\t\t<ToolsPanelItem\n\t\t\t\tlabel={ __( 'Poster image' ) }\n\t\t\t\tisShownByDefault\n\t\t\t\thasValue={ () => !! poster }\n\t\t\t\tonDeselect={ () => {\n\t\t\t\t\tsetAttributes( { poster: undefined } );\n\t\t\t\t} }\n\t\t\t>\n\t\t\t\t<BaseControl.VisualLabel>\n\t\t\t\t\t{ __( 'Poster image' ) }\n\t\t\t\t</BaseControl.VisualLabel>\n\t\t\t\t<HStack justify=\"flex-start\">\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={ posterButtonRef }\n\t\t\t\t\t\t\t\taria-describedby={ descriptionId }\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={ descriptionId } 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</HStack>\n\t\t\t</ToolsPanelItem>\n\t\t</MediaUploadCheck>\n\t);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AE,CAAE,cAAe;MAAC,CACE,CAAC,eAC1BO,KAAA,CAACV,MAAM;QAAC8B,OAAO,EAAC,YAAY;QAAAN,QAAA,gBAC3BhB,IAAA,CAACb,WAAW;UACXoC,KAAK,EAAG5B,EAAE,CAAE,qBAAsB,CAAG;UACrC6B,QAAQ,EAAGf,cAAgB;UAC3BgB,YAAY,EAAGtB,gCAAkC;UACjDuB,MAAM,EAAGA,CAAE;YAAEC;UAAK,CAAC,kBAClB3B,IAAA,CAACX,MAAM;YACNuC,qBAAqB;YACrBC,OAAO,EAAC,SAAS;YACjBC,OAAO,EAAGH,IAAM;YAChBI,GAAG,EAAGxB,eAAiB;YACvB,oBAAmBC,aAAe;YAAAQ,QAAA,EAEhC,CAAEX,MAAM,GAAGV,EAAE,CAAE,QAAS,CAAC,GAAGA,EAAE,CAAE,SAAU;UAAC,CACtC;QACN,CACH,CAAC,eACFK,IAAA;UAAGgC,EAAE,EAAGxB,aAAe;UAACyB,MAAM;UAAAjB,QAAA,EAC3BX,MAAM,GACLT,OAAO,CACP;UACAD,EAAE,CAAE,oCAAqC,CAAC,EAC1CU,MACA,CAAC,GACDV,EAAE,CACF,6CACA;QAAC,CACF,CAAC,EACF,CAAC,CAAEU,MAAM,iBACVL,IAAA,CAACX,MAAM;UACNuC,qBAAqB;UACrBE,OAAO,EAAGlB,cAAgB;UAC1BiB,OAAO,EAAC,UAAU;UAAAb,QAAA,EAEhBrB,EAAE,CAAE,QAAS;QAAC,CACT,CACR;MAAA,CACM,CAAC;IAAA,CACM;EAAC,CACA,CAAC;AAErB;AAEA,eAAeS,WAAW","ignoreList":[]}
@@ -1,91 +0,0 @@
1
- /**
2
- * WordPress dependencies
3
- */
4
- import { MediaUpload, MediaUploadCheck } from '@wordpress/block-editor';
5
- import {
6
- Button,
7
- BaseControl,
8
- __experimentalHStack as HStack,
9
- __experimentalToolsPanelItem as ToolsPanelItem,
10
- } from '@wordpress/components';
11
- import { __, sprintf } from '@wordpress/i18n';
12
- import { useRef } from '@wordpress/element';
13
- import { useInstanceId } from '@wordpress/compose';
14
-
15
- const COVER_POSTER_ALLOWED_MEDIA_TYPES = [ 'image' ];
16
-
17
- function PosterImage( { poster, setAttributes } ) {
18
- const posterButtonRef = useRef();
19
- const descriptionId = useInstanceId(
20
- PosterImage,
21
- 'cover-block__poster-image-description'
22
- );
23
-
24
- function onSelectPoster( image ) {
25
- setAttributes( { poster: image.url } );
26
- }
27
-
28
- function onRemovePoster() {
29
- setAttributes( { poster: undefined } );
30
-
31
- // Move focus back to the Media Upload button.
32
- posterButtonRef.current.focus();
33
- }
34
-
35
- return (
36
- <MediaUploadCheck>
37
- <ToolsPanelItem
38
- label={ __( 'Poster image' ) }
39
- isShownByDefault
40
- hasValue={ () => !! poster }
41
- onDeselect={ () => {
42
- setAttributes( { poster: undefined } );
43
- } }
44
- >
45
- <BaseControl.VisualLabel>
46
- { __( 'Poster image' ) }
47
- </BaseControl.VisualLabel>
48
- <HStack justify="flex-start">
49
- <MediaUpload
50
- title={ __( 'Select poster image' ) }
51
- onSelect={ onSelectPoster }
52
- allowedTypes={ COVER_POSTER_ALLOWED_MEDIA_TYPES }
53
- render={ ( { open } ) => (
54
- <Button
55
- __next40pxDefaultSize
56
- variant="primary"
57
- onClick={ open }
58
- ref={ posterButtonRef }
59
- aria-describedby={ descriptionId }
60
- >
61
- { ! poster ? __( 'Select' ) : __( 'Replace' ) }
62
- </Button>
63
- ) }
64
- />
65
- <p id={ descriptionId } hidden>
66
- { poster
67
- ? sprintf(
68
- /* translators: %s: poster image URL. */
69
- __( 'The current poster image url is %s.' ),
70
- poster
71
- )
72
- : __(
73
- 'There is no poster image currently selected.'
74
- ) }
75
- </p>
76
- { !! poster && (
77
- <Button
78
- __next40pxDefaultSize
79
- onClick={ onRemovePoster }
80
- variant="tertiary"
81
- >
82
- { __( 'Remove' ) }
83
- </Button>
84
- ) }
85
- </HStack>
86
- </ToolsPanelItem>
87
- </MediaUploadCheck>
88
- );
89
- }
90
-
91
- export default PosterImage;
@@ -1,91 +0,0 @@
1
- /**
2
- * WordPress dependencies
3
- */
4
- import { MediaUpload, MediaUploadCheck } from '@wordpress/block-editor';
5
- import {
6
- Button,
7
- BaseControl,
8
- __experimentalHStack as HStack,
9
- __experimentalToolsPanelItem as ToolsPanelItem,
10
- } from '@wordpress/components';
11
- import { __, sprintf } from '@wordpress/i18n';
12
- import { useRef } from '@wordpress/element';
13
- import { useInstanceId } from '@wordpress/compose';
14
-
15
- const VIDEO_POSTER_ALLOWED_MEDIA_TYPES = [ 'image' ];
16
-
17
- function PosterImage( { poster, setAttributes } ) {
18
- const posterButtonRef = useRef();
19
- const descriptionId = useInstanceId(
20
- PosterImage,
21
- 'video-block__poster-image-description'
22
- );
23
-
24
- function onSelectPoster( image ) {
25
- setAttributes( { poster: image.url } );
26
- }
27
-
28
- function onRemovePoster() {
29
- setAttributes( { poster: undefined } );
30
-
31
- // Move focus back to the Media Upload button.
32
- posterButtonRef.current.focus();
33
- }
34
-
35
- return (
36
- <MediaUploadCheck>
37
- <ToolsPanelItem
38
- label={ __( 'Poster image' ) }
39
- isShownByDefault
40
- hasValue={ () => !! poster }
41
- onDeselect={ () => {
42
- setAttributes( { poster: undefined } );
43
- } }
44
- >
45
- <BaseControl.VisualLabel>
46
- { __( 'Poster image' ) }
47
- </BaseControl.VisualLabel>
48
- <HStack justify="flex-start">
49
- <MediaUpload
50
- title={ __( 'Select poster image' ) }
51
- onSelect={ onSelectPoster }
52
- allowedTypes={ VIDEO_POSTER_ALLOWED_MEDIA_TYPES }
53
- render={ ( { open } ) => (
54
- <Button
55
- __next40pxDefaultSize
56
- variant="primary"
57
- onClick={ open }
58
- ref={ posterButtonRef }
59
- aria-describedby={ descriptionId }
60
- >
61
- { ! poster ? __( 'Select' ) : __( 'Replace' ) }
62
- </Button>
63
- ) }
64
- />
65
- <p id={ descriptionId } hidden>
66
- { poster
67
- ? sprintf(
68
- /* translators: %s: poster image URL. */
69
- __( 'The current poster image url is %s' ),
70
- poster
71
- )
72
- : __(
73
- 'There is no poster image currently selected'
74
- ) }
75
- </p>
76
- { !! poster && (
77
- <Button
78
- __next40pxDefaultSize
79
- onClick={ onRemovePoster }
80
- variant="tertiary"
81
- >
82
- { __( 'Remove' ) }
83
- </Button>
84
- ) }
85
- </HStack>
86
- </ToolsPanelItem>
87
- </MediaUploadCheck>
88
- );
89
- }
90
-
91
- export default PosterImage;