@wordpress/block-library 8.27.1 → 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.
- package/build/block/edit.js +4 -5
- package/build/block/edit.js.map +1 -1
- package/build/button/edit.js +2 -2
- package/build/button/edit.js.map +1 -1
- package/build/group/index.js +0 -1
- package/build/group/index.js.map +1 -1
- package/build/image/edit.js +17 -4
- package/build/image/edit.js.map +1 -1
- package/build/image/image.js +28 -28
- package/build/image/image.js.map +1 -1
- package/build-module/block/edit.js +4 -5
- package/build-module/block/edit.js.map +1 -1
- package/build-module/button/edit.js +2 -2
- package/build-module/button/edit.js.map +1 -1
- package/build-module/group/index.js +0 -1
- package/build-module/group/index.js.map +1 -1
- package/build-module/image/edit.js +17 -4
- package/build-module/image/edit.js.map +1 -1
- package/build-module/image/image.js +29 -29
- package/build-module/image/image.js.map +1 -1
- package/package.json +8 -8
- package/src/block/edit.js +3 -4
- package/src/button/edit.js +3 -4
- package/src/group/block.json +0 -1
- package/src/image/edit.js +23 -4
- package/src/image/image.js +23 -36
- package/src/navigation/index.php +9 -13
- package/src/pattern/index.php +2 -0
- package/src/post-navigation-link/index.php +3 -3
package/src/image/edit.js
CHANGED
|
@@ -25,6 +25,7 @@ import { store as noticesStore } from '@wordpress/notices';
|
|
|
25
25
|
/**
|
|
26
26
|
* Internal dependencies
|
|
27
27
|
*/
|
|
28
|
+
import { unlock } from '../lock-unlock';
|
|
28
29
|
import Image from './image';
|
|
29
30
|
|
|
30
31
|
/**
|
|
@@ -333,7 +334,25 @@ export function ImageEdit( {
|
|
|
333
334
|
} );
|
|
334
335
|
|
|
335
336
|
// Much of this description is duplicated from MediaPlaceholder.
|
|
336
|
-
const
|
|
337
|
+
const { lockUrlControls = false } = useSelect(
|
|
338
|
+
( select ) => {
|
|
339
|
+
if ( ! isSelected ) {
|
|
340
|
+
return {};
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
const { getBlockBindingsSource } = unlock(
|
|
344
|
+
select( blockEditorStore )
|
|
345
|
+
);
|
|
346
|
+
|
|
347
|
+
return {
|
|
348
|
+
lockUrlControls:
|
|
349
|
+
!! metadata?.bindings?.url &&
|
|
350
|
+
getBlockBindingsSource( metadata?.bindings?.url?.source )
|
|
351
|
+
?.lockAttributesEditing === true,
|
|
352
|
+
};
|
|
353
|
+
},
|
|
354
|
+
[ isSelected ]
|
|
355
|
+
);
|
|
337
356
|
const placeholder = ( content ) => {
|
|
338
357
|
return (
|
|
339
358
|
<Placeholder
|
|
@@ -342,10 +361,10 @@ export function ImageEdit( {
|
|
|
342
361
|
!! borderProps.className && ! isSelected,
|
|
343
362
|
} ) }
|
|
344
363
|
withIllustration={ true }
|
|
345
|
-
icon={
|
|
364
|
+
icon={ lockUrlControls ? pluginsIcon : icon }
|
|
346
365
|
label={ __( 'Image' ) }
|
|
347
366
|
instructions={
|
|
348
|
-
!
|
|
367
|
+
! lockUrlControls &&
|
|
349
368
|
__(
|
|
350
369
|
'Upload an image file, pick one from your media library, or add one with a URL.'
|
|
351
370
|
)
|
|
@@ -361,7 +380,7 @@ export function ImageEdit( {
|
|
|
361
380
|
...borderProps.style,
|
|
362
381
|
} }
|
|
363
382
|
>
|
|
364
|
-
{
|
|
383
|
+
{ lockUrlControls ? (
|
|
365
384
|
<span
|
|
366
385
|
className={ 'block-bindings-media-placeholder-message' }
|
|
367
386
|
>
|
package/src/image/image.js
CHANGED
|
@@ -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
|
|
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
|
|
448
|
+
getBlockBindingsSource( urlBinding?.source )
|
|
437
449
|
?.lockAttributesEditing === true,
|
|
438
450
|
lockAltControls:
|
|
439
451
|
!! altBinding &&
|
|
440
|
-
getBlockBindingsSource( altBinding?.source
|
|
452
|
+
getBlockBindingsSource( altBinding?.source )
|
|
441
453
|
?.lockAttributesEditing === true,
|
|
442
454
|
lockTitleControls:
|
|
443
455
|
!! titleBinding &&
|
|
444
|
-
getBlockBindingsSource( titleBinding?.source
|
|
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">
|
package/src/navigation/index.php
CHANGED
|
@@ -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( '
|
|
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];
|
|
@@ -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( '
|
|
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 );
|
|
@@ -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
|
|
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.
|
|
1426
|
-
// that are not present in Gutenberg's WP 6.
|
|
1427
|
-
if ( function_exists( '
|
|
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.
|
|
1458
|
-
// that are not present in Gutenberg's WP 6.
|
|
1459
|
-
if ( function_exists( '
|
|
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
|
}
|
package/src/pattern/index.php
CHANGED
|
@@ -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
|
-
* @
|
|
110
|
-
* @
|
|
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
|
|