@wordpress/block-library 8.19.3 → 8.19.5

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 (72) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/build/cover/edit/inspector-controls.js +1 -1
  3. package/build/cover/edit/inspector-controls.js.map +1 -1
  4. package/build/embed/edit.js +17 -0
  5. package/build/embed/edit.js.map +1 -1
  6. package/build/embed/edit.native.js +17 -0
  7. package/build/embed/edit.native.js.map +1 -1
  8. package/build/image/image.js +1 -1
  9. package/build/image/image.js.map +1 -1
  10. package/build/image/view.js +25 -6
  11. package/build/image/view.js.map +1 -1
  12. package/build/latest-posts/edit.js +6 -2
  13. package/build/latest-posts/edit.js.map +1 -1
  14. package/build/media-text/edit.js +1 -1
  15. package/build/media-text/edit.js.map +1 -1
  16. package/build/navigation/edit/deleted-navigation-warning.js +6 -4
  17. package/build/navigation/edit/deleted-navigation-warning.js.map +1 -1
  18. package/build/navigation/edit/index.js +3 -3
  19. package/build/navigation/edit/index.js.map +1 -1
  20. package/build/navigation/edit/inner-blocks.js +2 -1
  21. package/build/navigation/edit/inner-blocks.js.map +1 -1
  22. package/build/navigation/view.js +7 -0
  23. package/build/navigation/view.js.map +1 -1
  24. package/build-module/cover/edit/inspector-controls.js +1 -1
  25. package/build-module/cover/edit/inspector-controls.js.map +1 -1
  26. package/build-module/embed/edit.js +17 -0
  27. package/build-module/embed/edit.js.map +1 -1
  28. package/build-module/embed/edit.native.js +17 -0
  29. package/build-module/embed/edit.native.js.map +1 -1
  30. package/build-module/image/image.js +1 -1
  31. package/build-module/image/image.js.map +1 -1
  32. package/build-module/image/view.js +25 -6
  33. package/build-module/image/view.js.map +1 -1
  34. package/build-module/latest-posts/edit.js +6 -2
  35. package/build-module/latest-posts/edit.js.map +1 -1
  36. package/build-module/media-text/edit.js +1 -1
  37. package/build-module/media-text/edit.js.map +1 -1
  38. package/build-module/navigation/edit/deleted-navigation-warning.js +7 -4
  39. package/build-module/navigation/edit/deleted-navigation-warning.js.map +1 -1
  40. package/build-module/navigation/edit/index.js +3 -3
  41. package/build-module/navigation/edit/index.js.map +1 -1
  42. package/build-module/navigation/edit/inner-blocks.js +2 -1
  43. package/build-module/navigation/edit/inner-blocks.js.map +1 -1
  44. package/build-module/navigation/view.js +7 -0
  45. package/build-module/navigation/view.js.map +1 -1
  46. package/build-style/image/style-rtl.css +17 -2
  47. package/build-style/image/style.css +17 -2
  48. package/build-style/post-featured-image/style-rtl.css +3 -0
  49. package/build-style/post-featured-image/style.css +3 -0
  50. package/build-style/post-template/style-rtl.css +25 -0
  51. package/build-style/post-template/style.css +25 -0
  52. package/build-style/style-rtl.css +46 -2
  53. package/build-style/style.css +46 -2
  54. package/package.json +32 -32
  55. package/src/cover/edit/inspector-controls.js +1 -1
  56. package/src/embed/edit.js +15 -0
  57. package/src/embed/edit.native.js +15 -0
  58. package/src/image/image.js +1 -1
  59. package/src/image/index.php +65 -46
  60. package/src/image/style.scss +23 -2
  61. package/src/image/view.js +28 -7
  62. package/src/latest-posts/edit.js +11 -2
  63. package/src/latest-posts/index.php +17 -8
  64. package/src/media-text/edit.js +1 -1
  65. package/src/navigation/edit/deleted-navigation-warning.js +9 -4
  66. package/src/navigation/edit/index.js +26 -18
  67. package/src/navigation/edit/inner-blocks.js +1 -0
  68. package/src/navigation/index.php +19 -6
  69. package/src/navigation/view.js +7 -0
  70. package/src/post-featured-image/style.scss +4 -0
  71. package/src/post-template/style.scss +20 -0
  72. package/src/query/index.php +2 -1
package/src/image/view.js CHANGED
@@ -105,7 +105,10 @@ store(
105
105
  context.core.image.scrollDelta = 0;
106
106
 
107
107
  context.core.image.lightboxEnabled = true;
108
- setStyles( context, event );
108
+ setStyles(
109
+ context,
110
+ event.target.previousElementSibling
111
+ );
109
112
 
110
113
  context.core.image.scrollTopReset =
111
114
  window.pageYOffset ||
@@ -227,7 +230,17 @@ store(
227
230
  roleAttribute: ( { context } ) => {
228
231
  return context.core.image.lightboxEnabled
229
232
  ? 'dialog'
230
- : '';
233
+ : null;
234
+ },
235
+ ariaModal: ( { context } ) => {
236
+ return context.core.image.lightboxEnabled
237
+ ? 'true'
238
+ : null;
239
+ },
240
+ dialogLabel: ( { context } ) => {
241
+ return context.core.image.lightboxEnabled
242
+ ? context.core.image.dialogLabel
243
+ : null;
231
244
  },
232
245
  lightboxObjectFit: ( { context } ) => {
233
246
  if ( context.core.image.initialized ) {
@@ -237,7 +250,7 @@ store(
237
250
  enlargedImgSrc: ( { context } ) => {
238
251
  return context.core.image.initialized
239
252
  ? context.core.image.imageUploadedSrc
240
- : '';
253
+ : 'data:image/gif;base64,R0lGODlhAQABAAD/ACwAAAAAAQABAAACADs=';
241
254
  },
242
255
  },
243
256
  },
@@ -328,6 +341,15 @@ store(
328
341
  context.core.image.imageButtonHeight = offsetHeight;
329
342
  }
330
343
  },
344
+ setStylesOnResize: ( { state, context, ref } ) => {
345
+ if (
346
+ context.core.image.lightboxEnabled &&
347
+ ( state.core.image.windowWidth ||
348
+ state.core.image.windowHeight )
349
+ ) {
350
+ setStyles( context, ref );
351
+ }
352
+ },
331
353
  },
332
354
  },
333
355
  },
@@ -352,7 +374,7 @@ store(
352
374
  * @param {Object} context - An Interactivity API context
353
375
  * @param {Object} event - A triggering event
354
376
  */
355
- function setStyles( context, event ) {
377
+ function setStyles( context, ref ) {
356
378
  // The reference img element lies adjacent
357
379
  // to the event target button in the DOM.
358
380
  let {
@@ -360,9 +382,8 @@ function setStyles( context, event ) {
360
382
  naturalHeight,
361
383
  offsetWidth: originalWidth,
362
384
  offsetHeight: originalHeight,
363
- } = event.target.nextElementSibling;
364
- let { x: screenPosX, y: screenPosY } =
365
- event.target.nextElementSibling.getBoundingClientRect();
385
+ } = ref;
386
+ let { x: screenPosX, y: screenPosY } = ref.getBoundingClientRect();
366
387
 
367
388
  // Natural ratio of the image clicked to open the lightbox.
368
389
  const naturalRatio = naturalWidth / naturalHeight;
@@ -483,12 +483,18 @@ export default function LatestPostsEdit( { attributes, setAttributes } ) {
483
483
  .split( ' ', excerptLength )
484
484
  .join( ' ' ) }
485
485
  { createInterpolateElement(
486
- /* translators: excerpt truncation character, default … */
487
- __( ' <a>Read more</a>' ),
486
+ sprintf(
487
+ /* translators: 1: Hidden accessibility text: Post title */
488
+ __(
489
+ '… <a>Read more<span>: %1$s</span></a>'
490
+ ),
491
+ titleTrimmed || __( '(no title)' )
492
+ ),
488
493
  {
489
494
  a: (
490
495
  // eslint-disable-next-line jsx-a11y/anchor-has-content
491
496
  <a
497
+ className="wp-block-latest-posts__read-more"
492
498
  href={ post.link }
493
499
  rel="noopener noreferrer"
494
500
  onClick={
@@ -496,6 +502,9 @@ export default function LatestPostsEdit( { attributes, setAttributes } ) {
496
502
  }
497
503
  />
498
504
  ),
505
+ span: (
506
+ <span className="screen-reader-text" />
507
+ ),
499
508
  }
500
509
  ) }
501
510
  </>
@@ -48,14 +48,6 @@ function render_block_core_latest_posts( $attributes ) {
48
48
  $block_core_latest_posts_excerpt_length = $attributes['excerptLength'];
49
49
  add_filter( 'excerpt_length', 'block_core_latest_posts_get_excerpt_length', 20 );
50
50
 
51
- $filter_latest_posts_excerpt_more = static function ( $more ) use ( $attributes ) {
52
- $use_excerpt = 'excerpt' === $attributes['displayPostContentRadio'];
53
- /* translators: %1$s is a URL to a post, excerpt truncation character, default … */
54
- return $use_excerpt ? sprintf( __( ' … <a href="%1$s" rel="noopener noreferrer">Read more</a>' ), esc_url( get_permalink() ) ) : $more;
55
- };
56
-
57
- add_filter( 'excerpt_more', $filter_latest_posts_excerpt_more );
58
-
59
51
  if ( ! empty( $attributes['categories'] ) ) {
60
52
  $args['category__in'] = array_column( $attributes['categories'], 'id' );
61
53
  }
@@ -151,6 +143,23 @@ function render_block_core_latest_posts( $attributes ) {
151
143
 
152
144
  $trimmed_excerpt = get_the_excerpt( $post );
153
145
 
146
+ /*
147
+ * Adds a "Read more" link with screen reader text.
148
+ * [&hellip;] is the default excerpt ending from wp_trim_excerpt() in Core.
149
+ */
150
+ if ( str_ends_with( $trimmed_excerpt, ' [&hellip;]' ) ) {
151
+ $excerpt_length = (int) apply_filters( 'excerpt_length', $block_core_latest_posts_excerpt_length );
152
+ if ( $excerpt_length <= $block_core_latest_posts_excerpt_length ) {
153
+ $trimmed_excerpt = substr( $trimmed_excerpt, 0, -11 );
154
+ $trimmed_excerpt .= sprintf(
155
+ /* translators: 1: A URL to a post, 2: Hidden accessibility text: Post title */
156
+ __( '… <a href="%1$s" rel="noopener noreferrer">Read more<span class="screen-reader-text">: %2$s</span></a>' ),
157
+ esc_url( $post_link ),
158
+ esc_html( $title )
159
+ );
160
+ }
161
+ }
162
+
154
163
  if ( post_password_required( $post ) ) {
155
164
  $trimmed_excerpt = __( 'This content is password protected.' );
156
165
  }
@@ -244,7 +244,7 @@ function MediaTextEdit( { attributes, isSelected, setAttributes } ) {
244
244
  <ToggleControl
245
245
  __nextHasNoMarginBottom
246
246
  label={ __( 'Crop image to fill entire column' ) }
247
- checked={ imageFill }
247
+ checked={ !! imageFill }
248
248
  onChange={ () =>
249
249
  setAttributes( {
250
250
  imageFill: ! imageFill,
@@ -4,14 +4,19 @@
4
4
  import { Warning } from '@wordpress/block-editor';
5
5
  import { Button } from '@wordpress/components';
6
6
  import { __ } from '@wordpress/i18n';
7
+ import { createInterpolateElement } from '@wordpress/element';
7
8
 
8
9
  function DeletedNavigationWarning( { onCreateNew } ) {
9
10
  return (
10
11
  <Warning>
11
- { __( 'Navigation menu has been deleted or is unavailable. ' ) }
12
- <Button onClick={ onCreateNew } variant="link">
13
- { __( 'Create a new menu?' ) }
14
- </Button>
12
+ { createInterpolateElement(
13
+ __(
14
+ 'Navigation menu has been deleted or is unavailable. <button>Create a new menu?</button>'
15
+ ),
16
+ {
17
+ button: <Button onClick={ onCreateNew } variant="link" />,
18
+ }
19
+ ) }
15
20
  </Warning>
16
21
  );
17
22
  }
@@ -93,6 +93,7 @@ function Navigation( {
93
93
  // navigation block settings.
94
94
  hasSubmenuIndicatorSetting = true,
95
95
  customPlaceholder: CustomPlaceholder = null,
96
+ __unstableLayoutClassNames: layoutClassNames,
96
97
  } ) {
97
98
  const {
98
99
  openSubmenusOnClick,
@@ -293,23 +294,31 @@ function Navigation( {
293
294
  const isResponsive = 'never' !== overlayMenu;
294
295
  const blockProps = useBlockProps( {
295
296
  ref: navRef,
296
- className: classnames( className, {
297
- 'items-justified-right': justifyContent === 'right',
298
- 'items-justified-space-between': justifyContent === 'space-between',
299
- 'items-justified-left': justifyContent === 'left',
300
- 'items-justified-center': justifyContent === 'center',
301
- 'is-vertical': orientation === 'vertical',
302
- 'no-wrap': flexWrap === 'nowrap',
303
- 'is-responsive': isResponsive,
304
- 'has-text-color': !! textColor.color || !! textColor?.class,
305
- [ getColorClassName( 'color', textColor?.slug ) ]:
306
- !! textColor?.slug,
307
- 'has-background': !! backgroundColor.color || backgroundColor.class,
308
- [ getColorClassName( 'background-color', backgroundColor?.slug ) ]:
309
- !! backgroundColor?.slug,
310
- [ `has-text-decoration-${ textDecoration }` ]: textDecoration,
311
- 'block-editor-block-content-overlay': hasBlockOverlay,
312
- } ),
297
+ className: classnames(
298
+ className,
299
+ {
300
+ 'items-justified-right': justifyContent === 'right',
301
+ 'items-justified-space-between':
302
+ justifyContent === 'space-between',
303
+ 'items-justified-left': justifyContent === 'left',
304
+ 'items-justified-center': justifyContent === 'center',
305
+ 'is-vertical': orientation === 'vertical',
306
+ 'no-wrap': flexWrap === 'nowrap',
307
+ 'is-responsive': isResponsive,
308
+ 'has-text-color': !! textColor.color || !! textColor?.class,
309
+ [ getColorClassName( 'color', textColor?.slug ) ]:
310
+ !! textColor?.slug,
311
+ 'has-background':
312
+ !! backgroundColor.color || backgroundColor.class,
313
+ [ getColorClassName(
314
+ 'background-color',
315
+ backgroundColor?.slug
316
+ ) ]: !! backgroundColor?.slug,
317
+ [ `has-text-decoration-${ textDecoration }` ]: textDecoration,
318
+ 'block-editor-block-content-overlay': hasBlockOverlay,
319
+ },
320
+ layoutClassNames
321
+ ),
313
322
  style: {
314
323
  color: ! textColor?.slug && textColor?.color,
315
324
  backgroundColor: ! backgroundColor?.slug && backgroundColor?.color,
@@ -875,7 +884,6 @@ function Navigation( {
875
884
  <ResponsiveWrapper
876
885
  id={ clientId }
877
886
  onToggle={ setResponsiveMenuVisibility }
878
- label={ __( 'Menu' ) }
879
887
  hasIcon={ hasIcon }
880
888
  icon={ icon }
881
889
  isOpen={ isResponsiveMenuOpen }
@@ -118,6 +118,7 @@ export default function NavigationInnerBlocks( {
118
118
  : false,
119
119
  placeholder: showPlaceholder ? placeholder : undefined,
120
120
  __experimentalCaptureToolbars: true,
121
+ __unstableDisableLayoutClassNames: true,
121
122
  }
122
123
  );
123
124
 
@@ -696,9 +696,22 @@ function render_block_core_navigation( $attributes, $content, $block ) {
696
696
  $responsive_dialog_directives = '';
697
697
  $close_button_directives = '';
698
698
  if ( $should_load_view_script ) {
699
+ $nav_element_context = wp_json_encode(
700
+ array(
701
+ 'core' => array(
702
+ 'navigation' => array(
703
+ 'overlayOpenedBy' => array(),
704
+ 'type' => 'overlay',
705
+ 'roleAttribute' => '',
706
+ 'ariaLabel' => __( 'Menu' ),
707
+ ),
708
+ ),
709
+ ),
710
+ JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_AMP
711
+ );
699
712
  $nav_element_directives = '
700
713
  data-wp-interactive
701
- data-wp-context=\'{ "core": { "navigation": { "overlayOpenedBy": {}, "type": "overlay", "roleAttribute": "" } } }\'
714
+ data-wp-context=\'' . $nav_element_context . '\'
702
715
  ';
703
716
  $open_button_directives = '
704
717
  data-wp-on--click="actions.core.navigation.openMenuOnClick"
@@ -714,6 +727,7 @@ function render_block_core_navigation( $attributes, $content, $block ) {
714
727
  ';
715
728
  $responsive_dialog_directives = '
716
729
  data-wp-bind--aria-modal="selectors.core.navigation.ariaModal"
730
+ data-wp-bind--aria-label="selectors.core.navigation.ariaLabel"
717
731
  data-wp-bind--role="selectors.core.navigation.roleAttribute"
718
732
  data-wp-effect="effects.core.navigation.focusFirstElement"
719
733
  ';
@@ -723,11 +737,11 @@ function render_block_core_navigation( $attributes, $content, $block ) {
723
737
  }
724
738
 
725
739
  $responsive_container_markup = sprintf(
726
- '<button aria-haspopup="true" %3$s class="%6$s" %11$s>%9$s</button>
727
- <div class="%5$s" style="%7$s" id="%1$s" %12$s>
740
+ '<button aria-haspopup="true" %3$s class="%6$s" %10$s>%8$s</button>
741
+ <div class="%5$s" style="%7$s" id="%1$s" %11$s>
728
742
  <div class="wp-block-navigation__responsive-close" tabindex="-1">
729
- <div class="wp-block-navigation__responsive-dialog" aria-label="%8$s" %13$s>
730
- <button %4$s class="wp-block-navigation__responsive-container-close" %14$s>%10$s</button>
743
+ <div class="wp-block-navigation__responsive-dialog" %12$s>
744
+ <button %4$s class="wp-block-navigation__responsive-container-close" %13$s>%9$s</button>
731
745
  <div class="wp-block-navigation__responsive-container-content" id="%1$s-content">
732
746
  %2$s
733
747
  </div>
@@ -741,7 +755,6 @@ function render_block_core_navigation( $attributes, $content, $block ) {
741
755
  esc_attr( implode( ' ', $responsive_container_classes ) ),
742
756
  esc_attr( implode( ' ', $open_button_classes ) ),
743
757
  esc_attr( safecss_filter_attr( $colors['overlay_inline_styles'] ) ),
744
- __( 'Menu' ),
745
758
  $toggle_button_content,
746
759
  $toggle_close_button_content,
747
760
  $open_button_directives,
@@ -87,6 +87,13 @@ wpStore( {
87
87
  ? 'true'
88
88
  : null;
89
89
  },
90
+ ariaLabel: ( store ) => {
91
+ const { context, selectors } = store;
92
+ return context.core.navigation.type === 'overlay' &&
93
+ selectors.core.navigation.isMenuOpen( store )
94
+ ? context.core.navigation.ariaLabel
95
+ : null;
96
+ },
90
97
  isMenuOpen: ( { context } ) =>
91
98
  // The menu is opened if either `click`, `hover` or `focus` is true.
92
99
  Object.values(
@@ -39,4 +39,8 @@
39
39
  }
40
40
  }
41
41
  }
42
+
43
+ &:where(.alignleft, .alignright) {
44
+ width: 100%;
45
+ }
42
46
  }
@@ -37,3 +37,23 @@
37
37
  grid-template-columns: 1fr;
38
38
  }
39
39
  }
40
+
41
+ .wp-block-post-template-is-layout-constrained > li > .alignright,
42
+ .wp-block-post-template-is-layout-flow > li > .alignright {
43
+ float: right;
44
+ margin-inline-start: 2em;
45
+ margin-inline-end: 0;
46
+ }
47
+
48
+ .wp-block-post-template-is-layout-constrained > li > .alignleft,
49
+ .wp-block-post-template-is-layout-flow > li > .alignleft {
50
+ float: left;
51
+ margin-inline-start: 0;
52
+ margin-inline-end: 2em;
53
+ }
54
+
55
+ .wp-block-post-template-is-layout-constrained > li > .aligncenter,
56
+ .wp-block-post-template-is-layout-flow > li > .aligncenter {
57
+ margin-inline-start: auto;
58
+ margin-inline-end: auto;
59
+ }
@@ -34,7 +34,8 @@ function render_block_core_query( $attributes, $content, $block ) {
34
34
  'loadedText' => __( 'Page Loaded.' ),
35
35
  ),
36
36
  ),
37
- )
37
+ ),
38
+ JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_AMP
38
39
  )
39
40
  );
40
41
  $content = $p->get_updated_html();