@wordpress/block-library 9.27.1-next.46f643fa0.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 (117) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/build/cover/edit/index.js +1 -1
  3. package/build/cover/edit/index.js.map +1 -1
  4. package/build/cover/edit/inspector-controls.js +1 -1
  5. package/build/cover/edit/inspector-controls.js.map +1 -1
  6. package/build/file/edit.js +4 -2
  7. package/build/file/edit.js.map +1 -1
  8. package/build/file/edit.native.js +1 -1
  9. package/build/file/edit.native.js.map +1 -1
  10. package/build/file/transforms.js +6 -6
  11. package/build/file/transforms.js.map +1 -1
  12. package/build/file/utils/index.js +5 -0
  13. package/build/file/utils/index.js.map +1 -1
  14. package/build/gallery/use-get-media.js +3 -3
  15. package/build/gallery/use-get-media.js.map +1 -1
  16. package/build/gallery/use-get-media.native.js +3 -3
  17. package/build/gallery/use-get-media.native.js.map +1 -1
  18. package/build/image/edit.native.js +2 -2
  19. package/build/image/edit.native.js.map +1 -1
  20. package/build/image/image.js +1 -1
  21. package/build/image/image.js.map +1 -1
  22. package/build/list-item/edit.js +3 -0
  23. package/build/list-item/edit.js.map +1 -1
  24. package/build/media-text/edit.js +2 -2
  25. package/build/media-text/edit.js.map +1 -1
  26. package/build/more/edit.js +13 -28
  27. package/build/more/edit.js.map +1 -1
  28. package/build/post-comments-count/index.js +3 -0
  29. package/build/post-comments-count/index.js.map +1 -1
  30. package/build/post-comments-link/index.js +3 -0
  31. package/build/post-comments-link/index.js.map +1 -1
  32. package/build/post-featured-image/edit.js +2 -2
  33. package/build/post-featured-image/edit.js.map +1 -1
  34. package/build/site-logo/edit.js +2 -2
  35. package/build/site-logo/edit.js.map +1 -1
  36. package/build/social-link/icons/tiktok.js +2 -2
  37. package/build/social-link/icons/tiktok.js.map +1 -1
  38. package/build/utils/poster-image.js +54 -6
  39. package/build/utils/poster-image.js.map +1 -1
  40. package/build-module/cover/edit/index.js +1 -1
  41. package/build-module/cover/edit/index.js.map +1 -1
  42. package/build-module/cover/edit/inspector-controls.js +1 -1
  43. package/build-module/cover/edit/inspector-controls.js.map +1 -1
  44. package/build-module/file/edit.js +4 -2
  45. package/build-module/file/edit.js.map +1 -1
  46. package/build-module/file/edit.native.js +1 -1
  47. package/build-module/file/edit.native.js.map +1 -1
  48. package/build-module/file/transforms.js +6 -6
  49. package/build-module/file/transforms.js.map +1 -1
  50. package/build-module/file/utils/index.js +5 -0
  51. package/build-module/file/utils/index.js.map +1 -1
  52. package/build-module/gallery/use-get-media.js +3 -3
  53. package/build-module/gallery/use-get-media.js.map +1 -1
  54. package/build-module/gallery/use-get-media.native.js +3 -3
  55. package/build-module/gallery/use-get-media.native.js.map +1 -1
  56. package/build-module/image/edit.native.js +2 -2
  57. package/build-module/image/edit.native.js.map +1 -1
  58. package/build-module/image/image.js +1 -1
  59. package/build-module/image/image.js.map +1 -1
  60. package/build-module/list-item/edit.js +3 -0
  61. package/build-module/list-item/edit.js.map +1 -1
  62. package/build-module/media-text/edit.js +2 -2
  63. package/build-module/media-text/edit.js.map +1 -1
  64. package/build-module/more/edit.js +15 -29
  65. package/build-module/more/edit.js.map +1 -1
  66. package/build-module/post-comments-count/index.js +3 -0
  67. package/build-module/post-comments-count/index.js.map +1 -1
  68. package/build-module/post-comments-link/index.js +3 -0
  69. package/build-module/post-comments-link/index.js.map +1 -1
  70. package/build-module/post-featured-image/edit.js +2 -2
  71. package/build-module/post-featured-image/edit.js.map +1 -1
  72. package/build-module/site-logo/edit.js +2 -2
  73. package/build-module/site-logo/edit.js.map +1 -1
  74. package/build-module/social-link/icons/tiktok.js +2 -2
  75. package/build-module/social-link/icons/tiktok.js.map +1 -1
  76. package/build-module/utils/poster-image.js +57 -9
  77. package/build-module/utils/poster-image.js.map +1 -1
  78. package/build-style/editor-rtl.css +23 -26
  79. package/build-style/editor.css +23 -26
  80. package/build-style/gallery/style-rtl.css +1 -2
  81. package/build-style/gallery/style.css +1 -2
  82. package/build-style/image/style-rtl.css +1 -2
  83. package/build-style/image/style.css +1 -2
  84. package/build-style/more/editor-rtl.css +3 -11
  85. package/build-style/more/editor.css +3 -11
  86. package/build-style/post-featured-image/editor-rtl.css +1 -2
  87. package/build-style/post-featured-image/editor.css +1 -2
  88. package/build-style/style-rtl.css +2 -4
  89. package/build-style/style.css +2 -4
  90. package/package.json +35 -35
  91. package/src/block/index.php +33 -20
  92. package/src/cover/edit/index.js +8 -3
  93. package/src/cover/edit/inspector-controls.js +6 -1
  94. package/src/file/edit.js +9 -4
  95. package/src/file/edit.native.js +5 -1
  96. package/src/file/transforms.js +6 -6
  97. package/src/file/utils/index.js +5 -0
  98. package/src/form-input/index.php +4 -2
  99. package/src/gallery/use-get-media.js +9 -5
  100. package/src/gallery/use-get-media.native.js +10 -6
  101. package/src/image/edit.native.js +4 -2
  102. package/src/image/image.js +6 -1
  103. package/src/image/index.php +1 -1
  104. package/src/image/test/edit.native.js +16 -10
  105. package/src/list-item/edit.js +3 -0
  106. package/src/loginout/index.php +4 -2
  107. package/src/media-text/edit.js +16 -6
  108. package/src/more/edit.js +27 -33
  109. package/src/more/editor.scss +3 -12
  110. package/src/post-comments-count/block.json +3 -0
  111. package/src/post-comments-link/block.json +3 -0
  112. package/src/post-date/index.php +28 -32
  113. package/src/post-featured-image/edit.js +2 -2
  114. package/src/site-logo/edit.js +11 -4
  115. package/src/social-link/icons/tiktok.js +2 -2
  116. package/src/utils/poster-image.js +62 -17
  117. package/src/utils/poster-image.scss +23 -16
@@ -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
 
@@ -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
  },
@@ -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
  );
package/src/file/edit.js CHANGED
@@ -80,7 +80,11 @@ function FileEdit( { attributes, isSelected, setAttributes, clientId } ) {
80
80
  media:
81
81
  id === undefined
82
82
  ? undefined
83
- : select( coreStore ).getMedia( id ),
83
+ : select( coreStore ).getEntityRecord(
84
+ 'postType',
85
+ 'attachment',
86
+ id
87
+ ),
84
88
  } ),
85
89
  [ id ]
86
90
  );
@@ -128,9 +132,10 @@ function FileEdit( { attributes, isSelected, setAttributes, clientId } ) {
128
132
  return;
129
133
  }
130
134
 
131
- const isPdf = getFilename( newMedia.url )
132
- .toLowerCase()
133
- .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' );
134
139
  const pdfAttributes = {
135
140
  displayPreview: isPdf
136
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/ );
@@ -18,6 +18,7 @@ import {
18
18
  } from '@wordpress/icons';
19
19
  import { useMergeRefs } from '@wordpress/compose';
20
20
  import { useSelect } from '@wordpress/data';
21
+ import { displayShortcut } from '@wordpress/keycodes';
21
22
 
22
23
  /**
23
24
  * Internal dependencies
@@ -53,6 +54,7 @@ export function IndentUI( { clientId } ) {
53
54
  <ToolbarButton
54
55
  icon={ isRTL() ? formatOutdentRTL : formatOutdent }
55
56
  title={ __( 'Outdent' ) }
57
+ shortcut={ displayShortcut.shift( 'Tab' ) }
56
58
  description={ __( 'Outdent list item' ) }
57
59
  disabled={ ! canOutdent }
58
60
  onClick={ () => outdentListItem() }
@@ -60,6 +62,7 @@ export function IndentUI( { clientId } ) {
60
62
  <ToolbarButton
61
63
  icon={ isRTL() ? formatIndentRTL : formatIndent }
62
64
  title={ __( 'Indent' ) }
65
+ shortcut="Tab"
63
66
  description={ __( 'Indent list item' ) }
64
67
  disabled={ ! canIndent }
65
68
  onClick={ () => indentListItem() }
@@ -23,14 +23,16 @@ function render_block_core_loginout( $attributes ) {
23
23
  */
24
24
  $current_url = ( is_ssl() ? 'https://' : 'http://' ) . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
25
25
 
26
- $classes = is_user_logged_in() ? 'logged-in' : 'logged-out';
26
+ $user_logged_in = is_user_logged_in();
27
+
28
+ $classes = $user_logged_in ? 'logged-in' : 'logged-out';
27
29
  $contents = wp_loginout(
28
30
  isset( $attributes['redirectToCurrent'] ) && $attributes['redirectToCurrent'] ? $current_url : '',
29
31
  false
30
32
  );
31
33
 
32
34
  // If logged-out and displayLoginAsForm is true, show the login form.
33
- if ( ! is_user_logged_in() && ! empty( $attributes['displayLoginAsForm'] ) ) {
35
+ if ( ! $user_logged_in && ! empty( $attributes['displayLoginAsForm'] ) ) {
34
36
  // Add a class.
35
37
  $classes .= ' has-login-form';
36
38
 
@@ -199,9 +199,14 @@ function MediaTextEdit( {
199
199
  return {
200
200
  featuredImageMedia:
201
201
  featuredImage && useFeaturedImage
202
- ? select( coreStore ).getMedia( featuredImage, {
203
- context: 'view',
204
- } )
202
+ ? select( coreStore ).getEntityRecord(
203
+ 'postType',
204
+ 'attachment',
205
+ featuredImage,
206
+ {
207
+ context: 'view',
208
+ }
209
+ )
205
210
  : undefined,
206
211
  };
207
212
  },
@@ -213,9 +218,14 @@ function MediaTextEdit( {
213
218
  return {
214
219
  image:
215
220
  mediaId && isSelected
216
- ? select( coreStore ).getMedia( mediaId, {
217
- context: 'view',
218
- } )
221
+ ? select( coreStore ).getEntityRecord(
222
+ 'postType',
223
+ 'attachment',
224
+ mediaId,
225
+ {
226
+ context: 'view',
227
+ }
228
+ )
219
229
  : null,
220
230
  };
221
231
  },
package/src/more/edit.js CHANGED
@@ -7,9 +7,13 @@ import {
7
7
  __experimentalToolsPanelItem as ToolsPanelItem,
8
8
  ToggleControl,
9
9
  } from '@wordpress/components';
10
- import { InspectorControls, useBlockProps } from '@wordpress/block-editor';
11
- import { ENTER } from '@wordpress/keycodes';
10
+ import {
11
+ InspectorControls,
12
+ PlainText,
13
+ useBlockProps,
14
+ } from '@wordpress/block-editor';
12
15
  import { getDefaultBlockName, createBlock } from '@wordpress/blocks';
16
+
13
17
  /**
14
18
  * Internal dependencies
15
19
  */
@@ -22,29 +26,6 @@ export default function MoreEdit( {
22
26
  insertBlocksAfter,
23
27
  setAttributes,
24
28
  } ) {
25
- const onChangeInput = ( event ) => {
26
- setAttributes( {
27
- customText: event.target.value,
28
- } );
29
- };
30
-
31
- const onKeyDown = ( { keyCode } ) => {
32
- if ( keyCode === ENTER ) {
33
- insertBlocksAfter( [ createBlock( getDefaultBlockName() ) ] );
34
- }
35
- };
36
-
37
- const getHideExcerptHelp = ( checked ) =>
38
- checked
39
- ? __( 'The excerpt is hidden.' )
40
- : __( 'The excerpt is visible.' );
41
-
42
- const toggleHideExcerpt = () => setAttributes( { noTeaser: ! noTeaser } );
43
-
44
- const style = {
45
- width: `${ ( customText ? customText : DEFAULT_TEXT ).length + 1.2 }em`,
46
- };
47
-
48
29
  const dropdownMenuProps = useToolsPanelDropdownMenuProps();
49
30
 
50
31
  return (
@@ -73,21 +54,34 @@ export default function MoreEdit( {
73
54
  'Hide the excerpt on the full content page'
74
55
  ) }
75
56
  checked={ !! noTeaser }
76
- onChange={ toggleHideExcerpt }
77
- help={ getHideExcerptHelp }
57
+ onChange={ () =>
58
+ setAttributes( { noTeaser: ! noTeaser } )
59
+ }
60
+ help={ ( checked ) =>
61
+ checked
62
+ ? __( 'The excerpt is hidden.' )
63
+ : __( 'The excerpt is visible.' )
64
+ }
78
65
  />
79
66
  </ToolsPanelItem>
80
67
  </ToolsPanel>
81
68
  </InspectorControls>
82
69
  <div { ...useBlockProps() }>
83
- <input
84
- aria-label={ __( '“Read more” link text' ) }
85
- type="text"
70
+ <PlainText
71
+ __experimentalVersion={ 2 }
72
+ tagName="span"
73
+ aria-label={ __( '"Read more" text' ) }
86
74
  value={ customText }
87
75
  placeholder={ DEFAULT_TEXT }
88
- onChange={ onChangeInput }
89
- onKeyDown={ onKeyDown }
90
- style={ style }
76
+ onChange={ ( value ) =>
77
+ setAttributes( { customText: value } )
78
+ }
79
+ disableLineBreaks
80
+ __unstableOnSplitAtEnd={ () =>
81
+ insertBlocksAfter(
82
+ createBlock( getDefaultBlockName() )
83
+ )
84
+ }
91
85
  />
92
86
  </div>
93
87
  </>
@@ -11,27 +11,18 @@
11
11
  white-space: nowrap;
12
12
 
13
13
  // Label
14
- input[type="text"] {
14
+ .rich-text {
15
15
  position: relative;
16
16
  font-size: $default-font-size;
17
17
  text-transform: uppercase;
18
18
  font-weight: 600;
19
19
  font-family: $default-font;
20
20
  color: $gray-700;
21
- border: none;
22
- box-shadow: none;
21
+ display: inline-flex;
23
22
  white-space: nowrap;
24
23
  text-align: center;
25
- margin: 0;
26
- border-radius: 4px;
27
24
  background: $white;
28
- padding: 6px 8px;
29
- height: $button-size-small;
30
- max-width: 100%;
31
-
32
- &:focus {
33
- box-shadow: none;
34
- }
25
+ padding: 10px 36px;
35
26
  }
36
27
 
37
28
  // Dashed line
@@ -12,6 +12,9 @@
12
12
  }
13
13
  },
14
14
  "usesContext": [ "postId" ],
15
+ "example": {
16
+ "viewportWidth": 350
17
+ },
15
18
  "supports": {
16
19
  "html": false,
17
20
  "color": {
@@ -12,6 +12,9 @@
12
12
  "type": "string"
13
13
  }
14
14
  },
15
+ "example": {
16
+ "viewportWidth": 350
17
+ },
15
18
  "supports": {
16
19
  "html": false,
17
20
  "color": {