@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
@@ -1465,8 +1465,7 @@ figure.wp-block-gallery.has-nested-images {
1465
1465
  height: 100%;
1466
1466
  max-height: 40%;
1467
1467
  pointer-events: none;
1468
- -webkit-backdrop-filter: blur(3px);
1469
- backdrop-filter: blur(3px);
1468
+ backdrop-filter: blur(3px);
1470
1469
  -webkit-mask-image: linear-gradient(0deg, #000 20%, transparent 100%);
1471
1470
  mask-image: linear-gradient(0deg, #000 20%, transparent 100%);
1472
1471
  }
@@ -1741,8 +1740,7 @@ h6.has-text-align-left[style*=writing-mode]:where([style*=vertical-lr]) {
1741
1740
  opacity: 0;
1742
1741
  border: none;
1743
1742
  background-color: rgba(90, 90, 90, 0.25);
1744
- -webkit-backdrop-filter: blur(16px) saturate(180%);
1745
- backdrop-filter: blur(16px) saturate(180%);
1743
+ backdrop-filter: blur(16px) saturate(180%);
1746
1744
  cursor: zoom-in;
1747
1745
  display: flex;
1748
1746
  justify-content: center;
@@ -4197,6 +4195,7 @@ pre.wp-block-verse {
4197
4195
  }
4198
4196
  .wp-block-video video {
4199
4197
  width: 100%;
4198
+ height: auto;
4200
4199
  vertical-align: middle;
4201
4200
  }
4202
4201
  @supports (position: sticky) {
@@ -1473,8 +1473,7 @@ figure.wp-block-gallery.has-nested-images {
1473
1473
  height: 100%;
1474
1474
  max-height: 40%;
1475
1475
  pointer-events: none;
1476
- -webkit-backdrop-filter: blur(3px);
1477
- backdrop-filter: blur(3px);
1476
+ backdrop-filter: blur(3px);
1478
1477
  -webkit-mask-image: linear-gradient(0deg, #000 20%, transparent 100%);
1479
1478
  mask-image: linear-gradient(0deg, #000 20%, transparent 100%);
1480
1479
  }
@@ -1755,8 +1754,7 @@ h6.has-text-align-left[style*=writing-mode]:where([style*=vertical-lr]) {
1755
1754
  opacity: 0;
1756
1755
  border: none;
1757
1756
  background-color: rgba(90, 90, 90, 0.25);
1758
- -webkit-backdrop-filter: blur(16px) saturate(180%);
1759
- backdrop-filter: blur(16px) saturate(180%);
1757
+ backdrop-filter: blur(16px) saturate(180%);
1760
1758
  cursor: zoom-in;
1761
1759
  display: flex;
1762
1760
  justify-content: center;
@@ -4230,6 +4228,7 @@ pre.wp-block-verse {
4230
4228
  }
4231
4229
  .wp-block-video video {
4232
4230
  width: 100%;
4231
+ height: auto;
4233
4232
  vertical-align: middle;
4234
4233
  }
4235
4234
  @supports (position: sticky) {
@@ -139,6 +139,7 @@
139
139
  }
140
140
  .wp-block-video video {
141
141
  width: 100%;
142
+ height: auto;
142
143
  vertical-align: middle;
143
144
  }
144
145
  @supports (position: sticky) {
@@ -139,6 +139,7 @@
139
139
  }
140
140
  .wp-block-video video {
141
141
  width: 100%;
142
+ height: auto;
142
143
  vertical-align: middle;
143
144
  }
144
145
  @supports (position: sticky) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wordpress/block-library",
3
- "version": "9.27.0",
3
+ "version": "9.28.0",
4
4
  "description": "Block library for the WordPress editor.",
5
5
  "author": "The WordPress Contributors",
6
6
  "license": "GPL-2.0-or-later",
@@ -41,39 +41,39 @@
41
41
  ],
42
42
  "dependencies": {
43
43
  "@babel/runtime": "7.25.7",
44
- "@wordpress/a11y": "^4.27.0",
45
- "@wordpress/api-fetch": "^7.27.0",
46
- "@wordpress/autop": "^4.27.0",
47
- "@wordpress/blob": "^4.27.0",
48
- "@wordpress/block-editor": "^15.0.0",
49
- "@wordpress/blocks": "^15.0.0",
50
- "@wordpress/components": "^30.0.0",
51
- "@wordpress/compose": "^7.27.0",
52
- "@wordpress/core-data": "^7.27.0",
53
- "@wordpress/data": "^10.27.0",
54
- "@wordpress/date": "^5.27.0",
55
- "@wordpress/deprecated": "^4.27.0",
56
- "@wordpress/dom": "^4.27.0",
57
- "@wordpress/element": "^6.27.0",
58
- "@wordpress/escape-html": "^3.27.0",
59
- "@wordpress/hooks": "^4.27.0",
60
- "@wordpress/html-entities": "^4.27.0",
61
- "@wordpress/i18n": "^6.0.0",
62
- "@wordpress/icons": "^10.27.0",
63
- "@wordpress/interactivity": "^6.27.0",
64
- "@wordpress/interactivity-router": "^2.27.0",
65
- "@wordpress/keyboard-shortcuts": "^5.27.0",
66
- "@wordpress/keycodes": "^4.27.0",
67
- "@wordpress/notices": "^5.27.0",
68
- "@wordpress/patterns": "^2.27.0",
69
- "@wordpress/primitives": "^4.27.0",
70
- "@wordpress/private-apis": "^1.27.0",
71
- "@wordpress/reusable-blocks": "^5.27.0",
72
- "@wordpress/rich-text": "^7.27.0",
73
- "@wordpress/server-side-render": "^6.3.0",
74
- "@wordpress/url": "^4.27.0",
75
- "@wordpress/viewport": "^6.27.0",
76
- "@wordpress/wordcount": "^4.27.0",
44
+ "@wordpress/a11y": "^4.28.0",
45
+ "@wordpress/api-fetch": "^7.28.0",
46
+ "@wordpress/autop": "^4.28.0",
47
+ "@wordpress/blob": "^4.28.0",
48
+ "@wordpress/block-editor": "^15.1.0",
49
+ "@wordpress/blocks": "^15.1.0",
50
+ "@wordpress/components": "^30.1.0",
51
+ "@wordpress/compose": "^7.28.0",
52
+ "@wordpress/core-data": "^7.28.0",
53
+ "@wordpress/data": "^10.28.0",
54
+ "@wordpress/date": "^5.28.0",
55
+ "@wordpress/deprecated": "^4.28.0",
56
+ "@wordpress/dom": "^4.28.0",
57
+ "@wordpress/element": "^6.28.0",
58
+ "@wordpress/escape-html": "^3.28.0",
59
+ "@wordpress/hooks": "^4.28.0",
60
+ "@wordpress/html-entities": "^4.28.0",
61
+ "@wordpress/i18n": "^6.1.0",
62
+ "@wordpress/icons": "^10.28.0",
63
+ "@wordpress/interactivity": "^6.28.0",
64
+ "@wordpress/interactivity-router": "^2.28.0",
65
+ "@wordpress/keyboard-shortcuts": "^5.28.0",
66
+ "@wordpress/keycodes": "^4.28.0",
67
+ "@wordpress/notices": "^5.28.0",
68
+ "@wordpress/patterns": "^2.28.0",
69
+ "@wordpress/primitives": "^4.28.0",
70
+ "@wordpress/private-apis": "^1.28.0",
71
+ "@wordpress/reusable-blocks": "^5.28.0",
72
+ "@wordpress/rich-text": "^7.28.0",
73
+ "@wordpress/server-side-render": "^6.4.0",
74
+ "@wordpress/url": "^4.28.0",
75
+ "@wordpress/viewport": "^6.28.0",
76
+ "@wordpress/wordcount": "^4.28.0",
77
77
  "change-case": "^4.1.2",
78
78
  "clsx": "^2.1.1",
79
79
  "colord": "^2.7.0",
@@ -91,5 +91,5 @@
91
91
  "publishConfig": {
92
92
  "access": "public"
93
93
  },
94
- "gitHead": "abe06a6f2aef8d03c30ea9d5b3e133f041e523b1"
94
+ "gitHead": "28cc2098f5ee28f89096b638533796538f495f72"
95
95
  }
@@ -1,4 +1,4 @@
1
- <?php
1
+ <?php // phpcs:ignore WordPress.Files.FileName.InvalidClassFileName // Needed for WP_Block_Cloner helper class.
2
2
  /**
3
3
  * Server-side rendering of the `core/block` block.
4
4
  *
@@ -16,7 +16,7 @@
16
16
  *
17
17
  * @return string Rendered HTML of the referenced block.
18
18
  */
19
- function render_block_core_block( $attributes ) {
19
+ function render_block_core_block( $attributes, $content, $block_instance ) {
20
20
  static $seen_refs = array();
21
21
 
22
22
  if ( empty( $attributes['ref'] ) ) {
@@ -73,30 +73,43 @@ function render_block_core_block( $attributes ) {
73
73
  $attributes['content'] = $attributes['overrides'];
74
74
  }
75
75
 
76
+ // Apply Block Hooks.
77
+ $content = apply_block_hooks_to_content_from_post_object( $content, $reusable_block );
78
+
76
79
  /**
77
- * We set the `pattern/overrides` context through the `render_block_context`
78
- * filter so that it is available when a pattern's inner blocks are
79
- * rendering via do_blocks given it only receives the inner content.
80
+ * We attach the blocks from $content as inner blocks to the Synced Pattern block instance.
81
+ * This ensures that block context available to the Synced Pattern block instance is provided to
82
+ * those blocks.
80
83
  */
81
- $has_pattern_overrides = isset( $attributes['content'] ) && null !== get_block_bindings_source( 'core/pattern-overrides' );
82
- if ( $has_pattern_overrides ) {
83
- $filter_block_context = static function ( $context ) use ( $attributes ) {
84
- $context['pattern/overrides'] = $attributes['content'];
85
- return $context;
86
- };
87
- add_filter( 'render_block_context', $filter_block_context, 1 );
84
+ $block_instance->parsed_block['innerBlocks'] = parse_blocks( $content );
85
+ $block_instance->parsed_block['innerContent'] = array_fill( 0, count( $block_instance->parsed_block['innerBlocks'] ), null );
86
+ if ( method_exists( $block_instance, 'refresh_context_dependents' ) ) {
87
+ // WP_Block::refresh_context_dependents() was introduced in WordPress 6.8.
88
+ $block_instance->refresh_context_dependents();
89
+ } else {
90
+ // This branch can be removed once Gutenberg requires WordPress 6.8 or later.
91
+ // phpcs:ignore Gutenberg.Commenting.SinceTag.MissingClassSinceTag
92
+ class WP_Block_Cloner extends WP_Block {
93
+ /**
94
+ * Static methods of subclasses have access to protected properties
95
+ * of instances of the parent class.
96
+ * In this case, this gives us access to `available_context` and `registry`.
97
+ */
98
+ // phpcs:ignore Gutenberg.Commenting.SinceTag.MissingMethodSinceTag
99
+ public static function clone_instance( $instance ) {
100
+ return new WP_Block(
101
+ $instance->parsed_block,
102
+ $instance->available_context,
103
+ $instance->registry
104
+ );
105
+ }
106
+ }
107
+ $block_instance = WP_Block_Cloner::clone_instance( $block_instance );
88
108
  }
89
109
 
90
- // Apply Block Hooks.
91
- $content = apply_block_hooks_to_content_from_post_object( $content, $reusable_block );
92
-
93
- $content = do_blocks( $content );
110
+ $content = $block_instance->render( array( 'dynamic' => false ) );
94
111
  unset( $seen_refs[ $attributes['ref'] ] );
95
112
 
96
- if ( $has_pattern_overrides ) {
97
- remove_filter( 'render_block_context', $filter_block_context, 1 );
98
- }
99
-
100
113
  return $content;
101
114
  }
102
115
 
@@ -25,6 +25,8 @@ import { decodeEntities } from '@wordpress/html-entities';
25
25
  import { __, sprintf } from '@wordpress/i18n';
26
26
  import { pin } from '@wordpress/icons';
27
27
  import { useEntityRecords } from '@wordpress/core-data';
28
+ import { useDispatch } from '@wordpress/data';
29
+ import { store as noticeStore } from '@wordpress/notices';
28
30
 
29
31
  /**
30
32
  * Internal dependencies
@@ -44,6 +46,7 @@ export default function CategoriesEdit( {
44
46
  },
45
47
  setAttributes,
46
48
  className,
49
+ clientId,
47
50
  } ) {
48
51
  const selectId = useInstanceId( CategoriesEdit, 'blocks-category-select' );
49
52
 
@@ -70,6 +73,15 @@ export default function CategoriesEdit( {
70
73
  query
71
74
  );
72
75
 
76
+ const { createWarningNotice } = useDispatch( noticeStore );
77
+ const showRedirectionPreventedNotice = ( event ) => {
78
+ event.preventDefault();
79
+ createWarningNotice( __( 'Links are disabled in the editor.' ), {
80
+ id: `block-library/core/categories/redirection-prevented/${ clientId }`,
81
+ type: 'snackbar',
82
+ } );
83
+ };
84
+
73
85
  const getCategoriesList = ( parentId ) => {
74
86
  if ( ! categories?.length ) {
75
87
  return [];
@@ -99,7 +111,7 @@ export default function CategoriesEdit( {
99
111
  const { id, link, count, name } = category;
100
112
  return (
101
113
  <li key={ id } className={ `cat-item cat-item-${ id }` }>
102
- <a href={ link } target="_blank" rel="noreferrer noopener">
114
+ <a href={ link } onClick={ showRedirectionPreventedNotice }>
103
115
  { renderCategoryName( name ) }
104
116
  </a>
105
117
  { showPostCounts && ` (${ count })` }
@@ -120,9 +120,14 @@ function CoverEdit( {
120
120
  return {
121
121
  media:
122
122
  featuredImage && useFeaturedImage
123
- ? select( coreStore ).getMedia( featuredImage, {
124
- context: 'view',
125
- } )
123
+ ? select( coreStore ).getEntityRecord(
124
+ 'postType',
125
+ 'attachment',
126
+ featuredImage,
127
+ {
128
+ context: 'view',
129
+ }
130
+ )
126
131
  : undefined,
127
132
  };
128
133
  },
@@ -35,7 +35,7 @@ import { COVER_MIN_HEIGHT, mediaPosition } from '../shared';
35
35
  import { unlock } from '../../lock-unlock';
36
36
  import { useToolsPanelDropdownMenuProps } from '../../utils/hooks';
37
37
  import { DEFAULT_MEDIA_SIZE_SLUG } from '../constants';
38
- import PosterImage from './poster-image';
38
+ import PosterImage from '../../utils/poster-image';
39
39
 
40
40
  const { cleanEmptyObject, ResolutionTool, HTMLElementControl } = unlock(
41
41
  blockEditorPrivateApis
@@ -131,7 +131,12 @@ export default function CoverInspectorControls( {
131
131
  const image = useSelect(
132
132
  ( select ) =>
133
133
  id && isImageBackground
134
- ? select( coreStore ).getMedia( id, { context: 'view' } )
134
+ ? select( coreStore ).getEntityRecord(
135
+ 'postType',
136
+ 'attachment',
137
+ id,
138
+ { context: 'view' }
139
+ )
135
140
  : null,
136
141
  [ id, isImageBackground ]
137
142
  );
@@ -275,7 +280,11 @@ export default function CoverInspectorControls( {
275
280
  { isVideoBackground && (
276
281
  <PosterImage
277
282
  poster={ poster }
278
- setAttributes={ setAttributes }
283
+ onChange={ ( posterImage ) =>
284
+ setAttributes( {
285
+ poster: posterImage?.url,
286
+ } )
287
+ }
279
288
  />
280
289
  ) }
281
290
  { ! useFeaturedImage && url && ! isVideoBackground && (
package/src/editor.scss CHANGED
@@ -54,6 +54,7 @@
54
54
  @import "./post-featured-image/editor.scss";
55
55
  @import "./post-comments-form/editor.scss";
56
56
  @import "./editor-elements.scss";
57
+ @import "./utils/poster-image.scss";
57
58
 
58
59
  :root .editor-styles-wrapper {
59
60
  @include background-colors-deprecated();
package/src/file/edit.js CHANGED
@@ -29,6 +29,7 @@ import { __, _x } from '@wordpress/i18n';
29
29
  import { file as icon } from '@wordpress/icons';
30
30
  import { store as coreStore } from '@wordpress/core-data';
31
31
  import { store as noticesStore } from '@wordpress/notices';
32
+ import { getFilename } from '@wordpress/url';
32
33
 
33
34
  /**
34
35
  * Internal dependencies
@@ -79,7 +80,11 @@ function FileEdit( { attributes, isSelected, setAttributes, clientId } ) {
79
80
  media:
80
81
  id === undefined
81
82
  ? undefined
82
- : select( coreStore ).getMedia( id ),
83
+ : select( coreStore ).getEntityRecord(
84
+ 'postType',
85
+ 'attachment',
86
+ id
87
+ ),
83
88
  } ),
84
89
  [ id ]
85
90
  );
@@ -127,7 +132,10 @@ function FileEdit( { attributes, isSelected, setAttributes, clientId } ) {
127
132
  return;
128
133
  }
129
134
 
130
- const isPdf = newMedia.url.endsWith( '.pdf' );
135
+ const isPdf =
136
+ // Media Library and REST API use different properties for mime type.
137
+ ( newMedia.mime || newMedia.mime_type ) === 'application/pdf' ||
138
+ getFilename( newMedia.url ).toLowerCase().endsWith( '.pdf' );
131
139
  const pdfAttributes = {
132
140
  displayPreview: isPdf
133
141
  ? attributes.displayPreview ?? true
@@ -583,7 +583,11 @@ export default compose( [
583
583
  const isNotFileHref = id && getProtocol( href ) !== 'file:';
584
584
  return {
585
585
  media: isNotFileHref
586
- ? select( coreStore ).getMedia( id )
586
+ ? select( coreStore ).getEntityRecord(
587
+ 'postType',
588
+ 'attachment',
589
+ id
590
+ )
587
591
  : undefined,
588
592
  isSidebarOpened: isSelected && isEditorSidebarOpened(),
589
593
  wasBlockJustInserted: select(
@@ -104,8 +104,8 @@ const transforms = {
104
104
  if ( ! id ) {
105
105
  return false;
106
106
  }
107
- const { getMedia } = select( coreStore );
108
- const media = getMedia( id );
107
+ const { getEntityRecord } = select( coreStore );
108
+ const media = getEntityRecord( 'postType', 'attachment', id );
109
109
  return !! media && media.mime_type.includes( 'audio' );
110
110
  },
111
111
  transform: ( attributes ) => {
@@ -124,8 +124,8 @@ const transforms = {
124
124
  if ( ! id ) {
125
125
  return false;
126
126
  }
127
- const { getMedia } = select( coreStore );
128
- const media = getMedia( id );
127
+ const { getEntityRecord } = select( coreStore );
128
+ const media = getEntityRecord( 'postType', 'attachment', id );
129
129
  return !! media && media.mime_type.includes( 'video' );
130
130
  },
131
131
  transform: ( attributes ) => {
@@ -144,8 +144,8 @@ const transforms = {
144
144
  if ( ! id ) {
145
145
  return false;
146
146
  }
147
- const { getMedia } = select( coreStore );
148
- const media = getMedia( id );
147
+ const { getEntityRecord } = select( coreStore );
148
+ const media = getEntityRecord( 'postType', 'attachment', id );
149
149
  return !! media && media.mime_type.includes( 'image' );
150
150
  },
151
151
  transform: ( attributes ) => {
@@ -5,6 +5,11 @@
5
5
  * @return {boolean} Whether or not the browser supports inline PDFs.
6
6
  */
7
7
  export const browserSupportsPdfs = () => {
8
+ // Use native feature detection if available.
9
+ if ( window.navigator.pdfViewerEnabled ) {
10
+ return true;
11
+ }
12
+
8
13
  // Most mobile devices include "Mobi" in their UA.
9
14
  if ( window.navigator.userAgent.indexOf( 'Mobi' ) > -1 ) {
10
15
  return false;
@@ -19,10 +19,12 @@ function render_block_core_form_input( $attributes, $content ) {
19
19
  $visibility_permissions = $attributes['visibilityPermissions'];
20
20
  }
21
21
 
22
- if ( 'logged-in' === $visibility_permissions && ! is_user_logged_in() ) {
22
+ $user_logged_in = is_user_logged_in();
23
+
24
+ if ( 'logged-in' === $visibility_permissions && ! $user_logged_in ) {
23
25
  return '';
24
26
  }
25
- if ( 'logged-out' === $visibility_permissions && is_user_logged_in() ) {
27
+ if ( 'logged-out' === $visibility_permissions && $user_logged_in ) {
26
28
  return '';
27
29
  }
28
30
  return $content;
@@ -26,11 +26,15 @@ export default function useGetMedia( innerBlockImages ) {
26
26
  }
27
27
 
28
28
  return (
29
- select( coreStore ).getMediaItems( {
30
- include: imageIds.join( ',' ),
31
- per_page: -1,
32
- orderby: 'include',
33
- } ) ?? EMPTY_IMAGE_MEDIA
29
+ select( coreStore ).getEntityRecords(
30
+ 'postType',
31
+ 'attachment',
32
+ {
33
+ include: imageIds.join( ',' ),
34
+ per_page: -1,
35
+ orderby: 'include',
36
+ }
37
+ ) ?? EMPTY_IMAGE_MEDIA
34
38
  );
35
39
  },
36
40
  [ innerBlockImages ]
@@ -32,12 +32,16 @@ export default function useGetMedia( innerBlockImages = [] ) {
32
32
  }
33
33
 
34
34
  return (
35
- select( coreStore ).getMediaItems( {
36
- include: imageIds.join( ',' ),
37
- per_page:
38
- imageIds.length /* 'hard' limit necessary as unbounded queries aren't supported on native */,
39
- orderby: 'include',
40
- } ) ?? EMPTY_IMAGE_MEDIA
35
+ select( coreStore ).getEntityRecords(
36
+ 'postType',
37
+ 'attachment',
38
+ {
39
+ include: imageIds.join( ',' ),
40
+ per_page:
41
+ imageIds.length /* 'hard' limit necessary as unbounded queries aren't supported on native */,
42
+ orderby: 'include',
43
+ }
44
+ ) ?? EMPTY_IMAGE_MEDIA
41
45
  );
42
46
  },
43
47
  [ innerBlockImages ]
@@ -905,7 +905,7 @@ export class ImageEdit extends Component {
905
905
 
906
906
  export default compose( [
907
907
  withSelect( ( select, props ) => {
908
- const { getMedia } = select( coreStore );
908
+ const { getEntityRecord } = select( coreStore );
909
909
  const { getSettings, wasBlockJustInserted } =
910
910
  select( blockEditorStore );
911
911
  const { getEditedPostAttribute } = select( 'core/editor' );
@@ -926,7 +926,9 @@ export default compose( [
926
926
  isNotFileUrl &&
927
927
  url &&
928
928
  ! hasQueryArg( url, 'w' ) );
929
- const image = shouldGetMedia ? getMedia( id ) : null;
929
+ const image = shouldGetMedia
930
+ ? getEntityRecord( 'postType', 'attachment', id )
931
+ : null;
930
932
 
931
933
  return {
932
934
  image,
@@ -306,7 +306,12 @@ export default function Image( {
306
306
  const image = useSelect(
307
307
  ( select ) =>
308
308
  id && isSingleSelected
309
- ? select( coreStore ).getMedia( id, { context: 'view' } )
309
+ ? select( coreStore ).getEntityRecord(
310
+ 'postType',
311
+ 'attachment',
312
+ id,
313
+ { context: 'view' }
314
+ )
310
315
  : null,
311
316
  [ id, isSingleSelected ]
312
317
  );
@@ -100,7 +100,7 @@ function render_block_core_image( $attributes, $content, $block ) {
100
100
  *
101
101
  * @param array $block Block data.
102
102
  *
103
- * @return array Filtered block data.
103
+ * @return array|null Filtered block data.
104
104
  */
105
105
  function block_core_image_get_lightbox_settings( $block ) {
106
106
  // Gets the lightbox setting from the block attributes.
@@ -42,7 +42,9 @@ sendMediaUpload.mockImplementation( ( payload ) => {
42
42
  } );
43
43
 
44
44
  function mockGetMedia( media ) {
45
- jest.spyOn( select( coreStore ), 'getMedia' ).mockReturnValue( media );
45
+ jest.spyOn( select( coreStore ), 'getEntityRecord' ).mockReturnValue(
46
+ media
47
+ );
46
48
  }
47
49
 
48
50
  const FETCH_MEDIA = {
@@ -71,8 +73,12 @@ beforeEach( () => {
71
73
  // Mock media fetch requests
72
74
  setupApiFetch( [ FETCH_MEDIA ] );
73
75
 
74
- // Invalidate `getMedia` resolutions to allow requesting to the API the same media id
75
- dispatch( coreStore ).invalidateResolutionForStoreSelector( 'getMedia' );
76
+ // Invalidate `getEntityRecord` resolutions to allow requesting to the API the same media id
77
+ dispatch( coreStore ).invalidateResolution( 'getEntityRecord', [
78
+ 'postType',
79
+ 'attachment',
80
+ 1,
81
+ ] );
76
82
  } );
77
83
 
78
84
  afterEach( () => {
@@ -99,7 +105,7 @@ describe( 'Image Block', () => {
99
105
  <figcaption class="wp-element-caption">Mountain</figcaption></figure>
100
106
  <!-- /wp:image -->`;
101
107
  const screen = await initializeEditor( { initialHtml } );
102
- // Check that image is fetched via `getMedia`
108
+ // Check that image is fetched via `getEntityRecord`
103
109
  expect( apiFetch ).toHaveBeenCalledWith( FETCH_MEDIA.request );
104
110
 
105
111
  const [ imageBlock ] = screen.getAllByLabelText( /Image Block/ );
@@ -126,7 +132,7 @@ describe( 'Image Block', () => {
126
132
  <figcaption class="wp-element-caption">Mountain</figcaption></figure>
127
133
  <!-- /wp:image -->`;
128
134
  const screen = await initializeEditor( { initialHtml } );
129
- // Check that image is fetched via `getMedia`
135
+ // Check that image is fetched via `getEntityRecord`
130
136
  expect( apiFetch ).toHaveBeenCalledWith( FETCH_MEDIA.request );
131
137
 
132
138
  const [ imageBlock ] = screen.getAllByLabelText( /Image Block/ );
@@ -153,7 +159,7 @@ describe( 'Image Block', () => {
153
159
  <figcaption class="wp-element-caption">Mountain</figcaption></figure>
154
160
  <!-- /wp:image -->`;
155
161
  const screen = await initializeEditor( { initialHtml } );
156
- // Check that image is fetched via `getMedia`
162
+ // Check that image is fetched via `getEntityRecord`
157
163
  expect( apiFetch ).toHaveBeenCalledWith( FETCH_MEDIA.request );
158
164
 
159
165
  const [ imageBlock ] = screen.getAllByLabelText( /Image Block/ );
@@ -190,7 +196,7 @@ describe( 'Image Block', () => {
190
196
  <figcaption class="wp-element-caption">Mountain</figcaption></figure>
191
197
  <!-- /wp:image -->`;
192
198
  const screen = await initializeEditor( { initialHtml } );
193
- // Check that image is fetched via `getMedia`
199
+ // Check that image is fetched via `getEntityRecord`
194
200
  expect( apiFetch ).toHaveBeenCalledWith( FETCH_MEDIA.request );
195
201
 
196
202
  const [ imageBlock ] = screen.getAllByLabelText( /Image Block/ );
@@ -223,7 +229,7 @@ describe( 'Image Block', () => {
223
229
  <figcaption class="wp-element-caption">Mountain</figcaption></figure>
224
230
  <!-- /wp:image -->`;
225
231
  const screen = await initializeEditor( { initialHtml } );
226
- // Check that image is not fetched via `getMedia` due to the presence of query parameters in the URL.
232
+ // Check that image is not fetched via `getEntityRecord` due to the presence of query parameters in the URL.
227
233
  expect( apiFetch ).not.toHaveBeenCalledWith( FETCH_MEDIA.request );
228
234
 
229
235
  const [ imageBlock ] = screen.getAllByLabelText( /Image Block/ );
@@ -248,7 +254,7 @@ describe( 'Image Block', () => {
248
254
  <figcaption class="wp-element-caption">Mountain</figcaption></figure>
249
255
  <!-- /wp:image -->`;
250
256
  const screen = await initializeEditor( { initialHtml } );
251
- // Check that image is fetched via `getMedia`
257
+ // Check that image is fetched via `getEntityRecord`
252
258
  expect( apiFetch ).toHaveBeenCalledWith( FETCH_MEDIA.request );
253
259
 
254
260
  const [ imageBlock ] = screen.getAllByLabelText( /Image Block/ );
@@ -279,7 +285,7 @@ describe( 'Image Block', () => {
279
285
  </figure>
280
286
  <!-- /wp:image -->`;
281
287
  const screen = await initializeEditor( { initialHtml } );
282
- // Check that image is fetched via `getMedia`
288
+ // Check that image is fetched via `getEntityRecord`
283
289
  expect( apiFetch ).toHaveBeenCalledWith( FETCH_MEDIA.request );
284
290
 
285
291
  const [ imageBlock ] = screen.getAllByLabelText( /Image Block/ );
@@ -774,7 +774,6 @@ export default function LatestPostsEdit( { attributes, setAttributes } ) {
774
774
  { addLinkToFeaturedImage ? (
775
775
  <a
776
776
  href={ post.link }
777
- rel="noreferrer noopener"
778
777
  onClick={
779
778
  showRedirectionPreventedNotice
780
779
  }
@@ -789,7 +788,6 @@ export default function LatestPostsEdit( { attributes, setAttributes } ) {
789
788
  <a
790
789
  className="wp-block-latest-posts__post-title"
791
790
  href={ post.link }
792
- rel="noreferrer noopener"
793
791
  dangerouslySetInnerHTML={
794
792
  !! titleTrimmed
795
793
  ? {