@wordpress/block-library 8.27.0 → 8.27.2

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 (48) hide show
  1. package/build/block/edit.js +4 -5
  2. package/build/block/edit.js.map +1 -1
  3. package/build/button/edit.js +2 -2
  4. package/build/button/edit.js.map +1 -1
  5. package/build/cover/edit/index.js +2 -1
  6. package/build/cover/edit/index.js.map +1 -1
  7. package/build/cover/edit/inspector-controls.js +13 -1
  8. package/build/cover/edit/inspector-controls.js.map +1 -1
  9. package/build/cover/index.js +3 -0
  10. package/build/cover/index.js.map +1 -1
  11. package/build/image/edit.js +17 -4
  12. package/build/image/edit.js.map +1 -1
  13. package/build/image/image.js +28 -28
  14. package/build/image/image.js.map +1 -1
  15. package/build-module/block/edit.js +4 -5
  16. package/build-module/block/edit.js.map +1 -1
  17. package/build-module/button/edit.js +2 -2
  18. package/build-module/button/edit.js.map +1 -1
  19. package/build-module/cover/edit/index.js +2 -1
  20. package/build-module/cover/edit/index.js.map +1 -1
  21. package/build-module/cover/edit/inspector-controls.js +14 -2
  22. package/build-module/cover/edit/inspector-controls.js.map +1 -1
  23. package/build-module/cover/index.js +3 -0
  24. package/build-module/cover/index.js.map +1 -1
  25. package/build-module/image/edit.js +17 -4
  26. package/build-module/image/edit.js.map +1 -1
  27. package/build-module/image/image.js +29 -29
  28. package/build-module/image/image.js.map +1 -1
  29. package/build-style/cover/style-rtl.css +1 -2
  30. package/build-style/cover/style.css +1 -2
  31. package/build-style/style-rtl.css +1 -2
  32. package/build-style/style.css +1 -2
  33. package/package.json +10 -10
  34. package/src/block/edit.js +3 -4
  35. package/src/button/edit.js +3 -4
  36. package/src/cover/block.json +3 -0
  37. package/src/cover/edit/index.js +2 -1
  38. package/src/cover/edit/inspector-controls.js +14 -1
  39. package/src/cover/style.scss +2 -3
  40. package/src/file/index.php +3 -3
  41. package/src/image/edit.js +23 -4
  42. package/src/image/image.js +23 -36
  43. package/src/image/index.php +1 -1
  44. package/src/navigation/index.php +12 -16
  45. package/src/pattern/index.php +2 -0
  46. package/src/post-navigation-link/index.php +3 -3
  47. package/src/query/index.php +1 -1
  48. package/src/search/index.php +3 -3
@@ -7,7 +7,6 @@ import {
7
7
  ResizableBox,
8
8
  Spinner,
9
9
  TextareaControl,
10
- ToggleControl,
11
10
  TextControl,
12
11
  ToolbarButton,
13
12
  ToolbarGroup,
@@ -281,6 +280,22 @@ export default function Image( {
281
280
  setAttributes( props );
282
281
  }
283
282
 
283
+ function onSetLightbox( enable ) {
284
+ if ( enable && ! lightboxSetting?.enabled ) {
285
+ setAttributes( {
286
+ lightbox: { enabled: true },
287
+ } );
288
+ } else if ( ! enable && lightboxSetting?.enabled ) {
289
+ setAttributes( {
290
+ lightbox: { enabled: false },
291
+ } );
292
+ } else {
293
+ setAttributes( {
294
+ lightbox: undefined,
295
+ } );
296
+ }
297
+ }
298
+
284
299
  function onSetTitle( value ) {
285
300
  // This is the HTML title attribute, separate from the media object
286
301
  // title.
@@ -350,15 +365,12 @@ export default function Image( {
350
365
 
351
366
  const [ lightboxSetting ] = useSettings( 'lightbox' );
352
367
 
353
- const showLightboxToggle =
368
+ const showLightboxSetting =
354
369
  !! lightbox || lightboxSetting?.allowEditing === true;
355
370
 
356
371
  const lightboxChecked =
357
372
  !! lightbox?.enabled || ( ! lightbox && !! lightboxSetting?.enabled );
358
373
 
359
- const lightboxToggleDisabled =
360
- linkDestination && linkDestination !== 'none';
361
-
362
374
  const dimensionsControl = (
363
375
  <DimensionsTool
364
376
  value={ { width, height, scale, aspectRatio } }
@@ -433,15 +445,15 @@ export default function Image( {
433
445
  return {
434
446
  lockUrlControls:
435
447
  !! urlBinding &&
436
- getBlockBindingsSource( urlBinding?.source?.name )
448
+ getBlockBindingsSource( urlBinding?.source )
437
449
  ?.lockAttributesEditing === true,
438
450
  lockAltControls:
439
451
  !! altBinding &&
440
- getBlockBindingsSource( altBinding?.source?.name )
452
+ getBlockBindingsSource( altBinding?.source )
441
453
  ?.lockAttributesEditing === true,
442
454
  lockTitleControls:
443
455
  !! titleBinding &&
444
- getBlockBindingsSource( titleBinding?.source?.name )
456
+ getBlockBindingsSource( titleBinding?.source )
445
457
  ?.lockAttributesEditing === true,
446
458
  };
447
459
  },
@@ -463,6 +475,9 @@ export default function Image( {
463
475
  linkTarget={ linkTarget }
464
476
  linkClass={ linkClass }
465
477
  rel={ rel }
478
+ showLightboxSetting={ showLightboxSetting }
479
+ lightboxEnabled={ lightboxChecked }
480
+ onSetLightbox={ onSetLightbox }
466
481
  />
467
482
  ) }
468
483
  { allowCrop && (
@@ -559,34 +574,6 @@ export default function Image( {
559
574
  options={ imageSizeOptions }
560
575
  />
561
576
  ) }
562
- { showLightboxToggle && (
563
- <ToolsPanelItem
564
- hasValue={ () => !! lightbox }
565
- label={ __( 'Expand on click' ) }
566
- onDeselect={ () => {
567
- setAttributes( { lightbox: undefined } );
568
- } }
569
- isShownByDefault={ true }
570
- >
571
- <ToggleControl
572
- label={ __( 'Expand on click' ) }
573
- checked={ lightboxChecked }
574
- onChange={ ( newValue ) => {
575
- setAttributes( {
576
- lightbox: { enabled: newValue },
577
- } );
578
- } }
579
- disabled={ lightboxToggleDisabled }
580
- help={
581
- lightboxToggleDisabled
582
- ? __(
583
- '“Expand on click” scales the image up, and can’t be combined with a link.'
584
- )
585
- : ''
586
- }
587
- />
588
- </ToolsPanelItem>
589
- ) }
590
577
  </ToolsPanel>
591
578
  </InspectorControls>
592
579
  <InspectorControls group="advanced">
@@ -325,7 +325,7 @@ function register_block_core_image() {
325
325
 
326
326
  wp_register_script_module(
327
327
  '@wordpress/block-library/image',
328
- gutenberg_url( '/build/interactivity/image.min.js' ),
328
+ defined( 'IS_GUTENBERG_PLUGIN' ) && IS_GUTENBERG_PLUGIN ? gutenberg_url( '/build/interactivity/image.min.js' ) : includes_url( 'blocks/image/view.min.js' ),
329
329
  array( '@wordpress/interactivity' ),
330
330
  defined( 'GUTENBERG_VERSION' ) ? GUTENBERG_VERSION : get_bloginfo( 'version' )
331
331
  );
@@ -192,7 +192,7 @@ class WP_Navigation_Block_Renderer {
192
192
  // it encounters whitespace. This code strips it.
193
193
  $blocks = block_core_navigation_filter_out_empty_blocks( $parsed_blocks );
194
194
 
195
- if ( function_exists( 'get_hooked_blocks' ) ) {
195
+ if ( function_exists( 'get_hooked_block_markup' ) ) {
196
196
  // Run Block Hooks algorithm to inject hooked blocks.
197
197
  $markup = block_core_navigation_insert_hooked_blocks( $blocks, $navigation_post );
198
198
  $root_nav_block = parse_blocks( $markup )[0];
@@ -567,7 +567,7 @@ class WP_Navigation_Block_Renderer {
567
567
  */
568
568
  private static function handle_view_script_module_loading( $attributes, $block, $inner_blocks ) {
569
569
  if ( static::is_interactive( $attributes, $inner_blocks ) ) {
570
- wp_enqueue_script_module( '@wordpress/block-library/navigation-block' );
570
+ wp_enqueue_script_module( '@wordpress/block-library/navigation' );
571
571
  }
572
572
  }
573
573
 
@@ -992,7 +992,7 @@ function block_core_navigation_get_fallback_blocks() {
992
992
  // In this case default to the (Page List) fallback.
993
993
  $fallback_blocks = ! empty( $maybe_fallback ) ? $maybe_fallback : $fallback_blocks;
994
994
 
995
- if ( function_exists( 'get_hooked_blocks' ) ) {
995
+ if ( function_exists( 'get_hooked_block_markup' ) ) {
996
996
  // Run Block Hooks algorithm to inject hooked blocks.
997
997
  // We have to run it here because we need the post ID of the Navigation block to track ignored hooked blocks.
998
998
  $markup = block_core_navigation_insert_hooked_blocks( $fallback_blocks, $navigation_post );
@@ -1081,8 +1081,8 @@ function register_block_core_navigation() {
1081
1081
  );
1082
1082
 
1083
1083
  wp_register_script_module(
1084
- '@wordpress/block-library/navigation-block',
1085
- gutenberg_url( '/build/interactivity/navigation.min.js' ),
1084
+ '@wordpress/block-library/navigation',
1085
+ defined( 'IS_GUTENBERG_PLUGIN' ) && IS_GUTENBERG_PLUGIN ? gutenberg_url( '/build/interactivity/navigation.min.js' ) : includes_url( 'blocks/navigation/view.min.js' ),
1086
1086
  array( '@wordpress/interactivity' ),
1087
1087
  defined( 'GUTENBERG_VERSION' ) ? GUTENBERG_VERSION : get_bloginfo( 'version' )
1088
1088
  );
@@ -1358,7 +1358,7 @@ function block_core_navigation_get_most_recently_published_navigation() {
1358
1358
  * @param WP_Post $post `wp_navigation` post object corresponding to the block.
1359
1359
  * @return string Serialized inner blocks in mock Navigation block wrapper, with hooked blocks inserted, if any.
1360
1360
  */
1361
- function block_core_navigation_insert_hooked_blocks( $inner_blocks, $post = null ) {
1361
+ function block_core_navigation_insert_hooked_blocks( $inner_blocks, $post ) {
1362
1362
  $before_block_visitor = null;
1363
1363
  $after_block_visitor = null;
1364
1364
  $hooked_blocks = get_hooked_blocks();
@@ -1397,10 +1397,6 @@ function block_core_navigation_insert_hooked_blocks( $inner_blocks, $post = null
1397
1397
  * @param WP_Post $post Post object.
1398
1398
  */
1399
1399
  function block_core_navigation_update_ignore_hooked_blocks_meta( $post ) {
1400
- if ( ! isset( $post->ID ) ) {
1401
- return;
1402
- }
1403
-
1404
1400
  // We run the Block Hooks mechanism so it will return the list of ignored hooked blocks
1405
1401
  // in the mock root Navigation block's metadata attribute.
1406
1402
  // We ignore the rest of the returned `$markup`; `$post->post_content` already has the hooked
@@ -1422,9 +1418,9 @@ function block_core_navigation_update_ignore_hooked_blocks_meta( $post ) {
1422
1418
  }
1423
1419
  }
1424
1420
 
1425
- // Injection of hooked blocks into the Navigation block relies on some functions present in WP >= 6.4
1426
- // that are not present in Gutenberg's WP 6.4 compatibility layer.
1427
- if ( function_exists( 'get_hooked_blocks' ) ) {
1421
+ // Injection of hooked blocks into the Navigation block relies on some functions present in WP >= 6.5
1422
+ // that are not present in Gutenberg's WP 6.5 compatibility layer.
1423
+ if ( function_exists( 'get_hooked_block_markup' ) ) {
1428
1424
  add_action( 'rest_insert_wp_navigation', 'block_core_navigation_update_ignore_hooked_blocks_meta', 10, 3 );
1429
1425
  }
1430
1426
 
@@ -1454,8 +1450,8 @@ function block_core_navigation_insert_hooked_blocks_into_rest_response( $respons
1454
1450
  return $response;
1455
1451
  }
1456
1452
 
1457
- // Injection of hooked blocks into the Navigation block relies on some functions present in WP >= 6.4
1458
- // that are not present in Gutenberg's WP 6.4 compatibility layer.
1459
- if ( function_exists( 'get_hooked_blocks' ) ) {
1453
+ // Injection of hooked blocks into the Navigation block relies on some functions present in WP >= 6.5
1454
+ // that are not present in Gutenberg's WP 6.5 compatibility layer.
1455
+ if ( function_exists( 'get_hooked_block_markup' ) ) {
1460
1456
  add_filter( 'rest_prepare_wp_navigation', 'block_core_navigation_insert_hooked_blocks_into_rest_response', 10, 3 );
1461
1457
  }
@@ -22,6 +22,8 @@ function register_block_core_pattern() {
22
22
  *
23
23
  * @since 6.3.0 Backwards compatibility: blocks with no `syncStatus` attribute do not receive block wrapper.
24
24
  *
25
+ * @global WP_Embed $wp_embed Used to process embedded content within patterns
26
+ *
25
27
  * @param array $attributes Block attributes.
26
28
  *
27
29
  * @return string Returns the output of the pattern.
@@ -102,12 +102,12 @@ function render_block_core_post_navigation_link( $attributes, $content ) {
102
102
  $in_same_term = isset( $attributes['inSameTerm'] ) ? $attributes['inSameTerm'] : false;
103
103
  $taxonomy = isset( $attributes['taxonomy'] ) && $in_same_term ? $attributes['taxonomy'] : '';
104
104
 
105
- /**
105
+ /*
106
106
  * The dynamic portion of the function name, `$navigation_type`,
107
107
  * Refers to the type of adjacency, 'next' or 'previous'.
108
108
  *
109
- * @See https://developer.wordpress.org/reference/functions/get_previous_post_link/
110
- * @See https://developer.wordpress.org/reference/functions/get_next_post_link/
109
+ * @see https://developer.wordpress.org/reference/functions/get_previous_post_link/
110
+ * @see https://developer.wordpress.org/reference/functions/get_next_post_link/
111
111
  */
112
112
  $get_link_function = "get_{$navigation_type}_post_link";
113
113
 
@@ -101,7 +101,7 @@ function register_block_core_query() {
101
101
 
102
102
  wp_register_script_module(
103
103
  '@wordpress/block-library/query',
104
- gutenberg_url( '/build/interactivity/query.min.js' ),
104
+ defined( 'IS_GUTENBERG_PLUGIN' ) && IS_GUTENBERG_PLUGIN ? gutenberg_url( '/build/interactivity/query.min.js' ) : includes_url( 'blocks/query/view.min.js' ),
105
105
  array(
106
106
  array(
107
107
  'id' => '@wordpress/interactivity',
@@ -80,7 +80,7 @@ function render_block_core_search( $attributes ) {
80
80
  // If it's interactive, enqueue the script module and add the directives.
81
81
  $is_expandable_searchfield = 'button-only' === $button_position;
82
82
  if ( $is_expandable_searchfield ) {
83
- wp_enqueue_script_module( '@wordpress/block-library/search-block' );
83
+ wp_enqueue_script_module( '@wordpress/block-library/search' );
84
84
 
85
85
  $input->set_attribute( 'data-wp-bind--aria-hidden', '!context.isSearchInputVisible' );
86
86
  $input->set_attribute( 'data-wp-bind--tabindex', 'state.tabindex' );
@@ -198,8 +198,8 @@ function register_block_core_search() {
198
198
  );
199
199
 
200
200
  wp_register_script_module(
201
- '@wordpress/block-library/search-block',
202
- gutenberg_url( '/build/interactivity/search.min.js' ),
201
+ '@wordpress/block-library/search',
202
+ defined( 'IS_GUTENBERG_PLUGIN' ) && IS_GUTENBERG_PLUGIN ? gutenberg_url( '/build/interactivity/search.min.js' ) : includes_url( 'blocks/search/view.min.js' ),
203
203
  array( '@wordpress/interactivity' ),
204
204
  defined( 'GUTENBERG_VERSION' ) ? GUTENBERG_VERSION : get_bloginfo( 'version' )
205
205
  );