@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.
- package/CHANGELOG.md +2 -0
- package/build/cover/edit/index.js +1 -1
- package/build/cover/edit/index.js.map +1 -1
- package/build/cover/edit/inspector-controls.js +1 -1
- package/build/cover/edit/inspector-controls.js.map +1 -1
- package/build/file/edit.js +4 -2
- package/build/file/edit.js.map +1 -1
- package/build/file/edit.native.js +1 -1
- package/build/file/edit.native.js.map +1 -1
- package/build/file/transforms.js +6 -6
- package/build/file/transforms.js.map +1 -1
- package/build/file/utils/index.js +5 -0
- package/build/file/utils/index.js.map +1 -1
- package/build/gallery/use-get-media.js +3 -3
- package/build/gallery/use-get-media.js.map +1 -1
- package/build/gallery/use-get-media.native.js +3 -3
- package/build/gallery/use-get-media.native.js.map +1 -1
- package/build/image/edit.native.js +2 -2
- package/build/image/edit.native.js.map +1 -1
- package/build/image/image.js +1 -1
- package/build/image/image.js.map +1 -1
- package/build/list-item/edit.js +3 -0
- package/build/list-item/edit.js.map +1 -1
- package/build/media-text/edit.js +2 -2
- package/build/media-text/edit.js.map +1 -1
- package/build/more/edit.js +13 -28
- package/build/more/edit.js.map +1 -1
- package/build/post-comments-count/index.js +3 -0
- package/build/post-comments-count/index.js.map +1 -1
- package/build/post-comments-link/index.js +3 -0
- package/build/post-comments-link/index.js.map +1 -1
- package/build/post-featured-image/edit.js +2 -2
- package/build/post-featured-image/edit.js.map +1 -1
- package/build/site-logo/edit.js +2 -2
- package/build/site-logo/edit.js.map +1 -1
- package/build/social-link/icons/tiktok.js +2 -2
- package/build/social-link/icons/tiktok.js.map +1 -1
- package/build/utils/poster-image.js +54 -6
- package/build/utils/poster-image.js.map +1 -1
- package/build-module/cover/edit/index.js +1 -1
- package/build-module/cover/edit/index.js.map +1 -1
- package/build-module/cover/edit/inspector-controls.js +1 -1
- package/build-module/cover/edit/inspector-controls.js.map +1 -1
- package/build-module/file/edit.js +4 -2
- package/build-module/file/edit.js.map +1 -1
- package/build-module/file/edit.native.js +1 -1
- package/build-module/file/edit.native.js.map +1 -1
- package/build-module/file/transforms.js +6 -6
- package/build-module/file/transforms.js.map +1 -1
- package/build-module/file/utils/index.js +5 -0
- package/build-module/file/utils/index.js.map +1 -1
- package/build-module/gallery/use-get-media.js +3 -3
- package/build-module/gallery/use-get-media.js.map +1 -1
- package/build-module/gallery/use-get-media.native.js +3 -3
- package/build-module/gallery/use-get-media.native.js.map +1 -1
- package/build-module/image/edit.native.js +2 -2
- package/build-module/image/edit.native.js.map +1 -1
- package/build-module/image/image.js +1 -1
- package/build-module/image/image.js.map +1 -1
- package/build-module/list-item/edit.js +3 -0
- package/build-module/list-item/edit.js.map +1 -1
- package/build-module/media-text/edit.js +2 -2
- package/build-module/media-text/edit.js.map +1 -1
- package/build-module/more/edit.js +15 -29
- package/build-module/more/edit.js.map +1 -1
- package/build-module/post-comments-count/index.js +3 -0
- package/build-module/post-comments-count/index.js.map +1 -1
- package/build-module/post-comments-link/index.js +3 -0
- package/build-module/post-comments-link/index.js.map +1 -1
- package/build-module/post-featured-image/edit.js +2 -2
- package/build-module/post-featured-image/edit.js.map +1 -1
- package/build-module/site-logo/edit.js +2 -2
- package/build-module/site-logo/edit.js.map +1 -1
- package/build-module/social-link/icons/tiktok.js +2 -2
- package/build-module/social-link/icons/tiktok.js.map +1 -1
- package/build-module/utils/poster-image.js +57 -9
- package/build-module/utils/poster-image.js.map +1 -1
- package/build-style/editor-rtl.css +23 -26
- package/build-style/editor.css +23 -26
- package/build-style/gallery/style-rtl.css +1 -2
- package/build-style/gallery/style.css +1 -2
- package/build-style/image/style-rtl.css +1 -2
- package/build-style/image/style.css +1 -2
- package/build-style/more/editor-rtl.css +3 -11
- package/build-style/more/editor.css +3 -11
- package/build-style/post-featured-image/editor-rtl.css +1 -2
- package/build-style/post-featured-image/editor.css +1 -2
- package/build-style/style-rtl.css +2 -4
- package/build-style/style.css +2 -4
- package/package.json +35 -35
- package/src/block/index.php +33 -20
- package/src/cover/edit/index.js +8 -3
- package/src/cover/edit/inspector-controls.js +6 -1
- package/src/file/edit.js +9 -4
- package/src/file/edit.native.js +5 -1
- package/src/file/transforms.js +6 -6
- package/src/file/utils/index.js +5 -0
- package/src/form-input/index.php +4 -2
- package/src/gallery/use-get-media.js +9 -5
- package/src/gallery/use-get-media.native.js +10 -6
- package/src/image/edit.native.js +4 -2
- package/src/image/image.js +6 -1
- package/src/image/index.php +1 -1
- package/src/image/test/edit.native.js +16 -10
- package/src/list-item/edit.js +3 -0
- package/src/loginout/index.php +4 -2
- package/src/media-text/edit.js +16 -6
- package/src/more/edit.js +27 -33
- package/src/more/editor.scss +3 -12
- package/src/post-comments-count/block.json +3 -0
- package/src/post-comments-link/block.json +3 -0
- package/src/post-date/index.php +28 -32
- package/src/post-featured-image/edit.js +2 -2
- package/src/site-logo/edit.js +11 -4
- package/src/social-link/icons/tiktok.js +2 -2
- package/src/utils/poster-image.js +62 -17
- package/src/utils/poster-image.scss +23 -16
package/src/post-date/index.php
CHANGED
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
* Renders the `core/post-date` block on the server.
|
|
10
10
|
*
|
|
11
11
|
* @since 5.8.0
|
|
12
|
+
* @since 6.9.0 Added `datetime` attribute and Block Bindings support.
|
|
12
13
|
*
|
|
13
14
|
* @param array $attributes Block attributes.
|
|
14
15
|
* @param string $content Block default content.
|
|
@@ -18,44 +19,39 @@
|
|
|
18
19
|
function render_block_core_post_date( $attributes, $content, $block ) {
|
|
19
20
|
$classes = array();
|
|
20
21
|
|
|
21
|
-
if (
|
|
22
|
+
if (
|
|
23
|
+
isset( $attributes['metadata']['bindings']['datetime']['source'] ) &&
|
|
24
|
+
isset( $attributes['metadata']['bindings']['datetime']['args'] )
|
|
25
|
+
) {
|
|
22
26
|
/*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
* 2. The `datetime` attribute is bound to a Block Bindings source, but we're on a version of WordPress
|
|
27
|
-
* that doesn't support binding that attribute to a Block Bindings source.
|
|
28
|
-
*
|
|
29
|
-
* In both cases, we set the `datetime` attribute to its correct value by applying Block Bindings manually.
|
|
27
|
+
* We might be running on a version of WordPress that doesn't support binding the block's `datetime` attribute
|
|
28
|
+
* to a Block Bindings source. In this case, we need to manually set the `datetime` attribute to its correct value.
|
|
29
|
+
* This branch can be removed once the minimum required WordPress version is 6.9 or newer.
|
|
30
30
|
*/
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
)
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
31
|
+
$source = get_block_bindings_source( $attributes['metadata']['bindings']['datetime']['source'] );
|
|
32
|
+
$source_args = $attributes['metadata']['bindings']['datetime']['args'];
|
|
33
|
+
|
|
34
|
+
$attributes['datetime'] = $source->get_value( $source_args, $block, 'datetime' );
|
|
35
|
+
} elseif ( ! isset( $attributes['datetime'] ) ) {
|
|
36
|
+
/*
|
|
37
|
+
* This is the legacy version of the block that didn't have the `datetime` attribute.
|
|
38
|
+
* This branch needs to be kept for backward compatibility.
|
|
39
|
+
*/
|
|
40
|
+
$source = get_block_bindings_source( 'core/post-data' );
|
|
41
|
+
if ( isset( $attributes['displayType'] ) && 'modified' === $attributes['displayType'] ) {
|
|
42
|
+
$source_args = array(
|
|
43
|
+
'key' => 'modified',
|
|
44
|
+
);
|
|
39
45
|
} else {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
if ( isset( $attributes['displayType'] ) && 'modified' === $attributes['displayType'] ) {
|
|
44
|
-
$source_args = array(
|
|
45
|
-
'key' => 'modified',
|
|
46
|
-
);
|
|
47
|
-
} else {
|
|
48
|
-
$source_args = array(
|
|
49
|
-
'key' => 'date',
|
|
50
|
-
);
|
|
51
|
-
}
|
|
46
|
+
$source_args = array(
|
|
47
|
+
'key' => 'date',
|
|
48
|
+
);
|
|
52
49
|
}
|
|
53
|
-
|
|
54
50
|
$attributes['datetime'] = $source->get_value( $source_args, $block, 'datetime' );
|
|
51
|
+
}
|
|
55
52
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
}
|
|
53
|
+
if ( isset( $source_args['key'] ) && 'modified' === $source_args['key'] ) {
|
|
54
|
+
$classes[] = 'wp-block-post-date__modified-date';
|
|
59
55
|
}
|
|
60
56
|
|
|
61
57
|
if ( empty( $attributes['datetime'] ) ) {
|
|
@@ -133,12 +133,12 @@ export default function PostFeaturedImageEdit( {
|
|
|
133
133
|
|
|
134
134
|
const { media, postType, postPermalink } = useSelect(
|
|
135
135
|
( select ) => {
|
|
136
|
-
const {
|
|
136
|
+
const { getEntityRecord, getPostType, getEditedEntityRecord } =
|
|
137
137
|
select( coreStore );
|
|
138
138
|
return {
|
|
139
139
|
media:
|
|
140
140
|
featuredImage &&
|
|
141
|
-
|
|
141
|
+
getEntityRecord( 'postType', 'attachment', featuredImage, {
|
|
142
142
|
context: 'view',
|
|
143
143
|
} ),
|
|
144
144
|
postType: postTypeSlug && getPostType( postTypeSlug ),
|
package/src/site-logo/edit.js
CHANGED
|
@@ -454,12 +454,19 @@ export default function LogoEdit( {
|
|
|
454
454
|
const _siteIconId = siteSettings?.site_icon;
|
|
455
455
|
const mediaItem =
|
|
456
456
|
_siteLogoId &&
|
|
457
|
-
select( coreStore ).
|
|
458
|
-
|
|
459
|
-
|
|
457
|
+
select( coreStore ).getEntityRecord(
|
|
458
|
+
'postType',
|
|
459
|
+
'attachment',
|
|
460
|
+
_siteLogoId,
|
|
461
|
+
{
|
|
462
|
+
context: 'view',
|
|
463
|
+
}
|
|
464
|
+
);
|
|
460
465
|
const _isRequestingMediaItem =
|
|
461
466
|
!! _siteLogoId &&
|
|
462
|
-
! select( coreStore ).hasFinishedResolution( '
|
|
467
|
+
! select( coreStore ).hasFinishedResolution( 'getEntityRecord', [
|
|
468
|
+
'postType',
|
|
469
|
+
'attachment',
|
|
463
470
|
_siteLogoId,
|
|
464
471
|
{ context: 'view' },
|
|
465
472
|
] );
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
import { Path, SVG } from '@wordpress/primitives';
|
|
5
5
|
|
|
6
6
|
export const TiktokIcon = () => (
|
|
7
|
-
<SVG width="24" height="24" viewBox="0 0
|
|
8
|
-
<Path d="
|
|
7
|
+
<SVG width="24" height="24" viewBox="0 0 24 24" version="1.1">
|
|
8
|
+
<Path d="M12.4044 3.01519C13.4086 3 14.4072 3.009 15.4045 3C15.465 4.14812 15.8874 5.31762 16.7472 6.12935C17.6053 6.96134 18.819 7.34217 20 7.47099V10.4912C18.8933 10.4558 17.7814 10.2308 16.7771 9.76499C16.3397 9.57148 15.9323 9.32227 15.5334 9.06745C15.5283 11.2591 15.5426 13.4479 15.5191 15.6305C15.4592 16.679 15.1053 17.7225 14.4814 18.5866C13.4777 20.025 11.7356 20.9627 9.94635 20.992C8.84885 21.0533 7.7525 20.7608 6.81729 20.2219C5.26743 19.3286 4.17683 17.6933 4.01799 15.9382C3.99957 15.563 3.99324 15.1883 4.00878 14.8221C4.14691 13.395 4.86917 12.0297 5.99027 11.101C7.26101 10.0192 9.04107 9.50397 10.7078 9.80886C10.7233 10.9199 10.6778 12.0297 10.6778 13.1407C9.91643 12.9 9.02668 12.9675 8.36139 13.4192C7.87566 13.7269 7.50675 14.1983 7.31453 14.7316C7.15569 15.1118 7.20116 15.5343 7.21036 15.9382C7.3928 17.169 8.60368 18.2035 9.89628 18.0916C10.7532 18.0826 11.5745 17.5965 12.0211 16.8849C12.1655 16.6357 12.3273 16.3809 12.3359 16.0878C12.4113 14.7462 12.3814 13.4102 12.3906 12.0685C12.3969 9.04495 12.3814 6.02979 12.4049 3.01575L12.4044 3.01519Z" />
|
|
9
9
|
</SVG>
|
|
10
10
|
);
|
|
@@ -6,26 +6,73 @@ import clsx from 'clsx';
|
|
|
6
6
|
/**
|
|
7
7
|
* WordPress dependencies
|
|
8
8
|
*/
|
|
9
|
-
import {
|
|
9
|
+
import {
|
|
10
|
+
MediaUpload,
|
|
11
|
+
MediaUploadCheck,
|
|
12
|
+
store as blockEditorStore,
|
|
13
|
+
} from '@wordpress/block-editor';
|
|
14
|
+
import { store as noticesStore } from '@wordpress/notices';
|
|
10
15
|
import {
|
|
11
16
|
Button,
|
|
12
17
|
BaseControl,
|
|
18
|
+
DropZone,
|
|
19
|
+
Spinner,
|
|
13
20
|
__experimentalHStack as HStack,
|
|
14
21
|
__experimentalToolsPanelItem as ToolsPanelItem,
|
|
15
22
|
} from '@wordpress/components';
|
|
23
|
+
import { isBlobURL } from '@wordpress/blob';
|
|
16
24
|
import { __, sprintf } from '@wordpress/i18n';
|
|
17
|
-
import { useRef } from '@wordpress/element';
|
|
25
|
+
import { useRef, useState } from '@wordpress/element';
|
|
18
26
|
import { useInstanceId } from '@wordpress/compose';
|
|
27
|
+
import { useSelect, useDispatch } from '@wordpress/data';
|
|
19
28
|
|
|
20
29
|
const POSTER_IMAGE_ALLOWED_MEDIA_TYPES = [ 'image' ];
|
|
21
30
|
|
|
22
31
|
function PosterImage( { poster, onChange } ) {
|
|
23
32
|
const posterButtonRef = useRef();
|
|
33
|
+
const [ isLoading, setIsLoading ] = useState( false );
|
|
24
34
|
const descriptionId = useInstanceId(
|
|
25
35
|
PosterImage,
|
|
26
36
|
'block-library-poster-image-description'
|
|
27
37
|
);
|
|
28
38
|
|
|
39
|
+
const { getSettings } = useSelect( blockEditorStore );
|
|
40
|
+
const { createErrorNotice } = useDispatch( noticesStore );
|
|
41
|
+
|
|
42
|
+
const onDropFiles = ( filesList ) => {
|
|
43
|
+
getSettings().mediaUpload( {
|
|
44
|
+
allowedTypes: POSTER_IMAGE_ALLOWED_MEDIA_TYPES,
|
|
45
|
+
filesList,
|
|
46
|
+
onFileChange: ( [ image ] ) => {
|
|
47
|
+
if ( isBlobURL( image?.url ) ) {
|
|
48
|
+
setIsLoading( true );
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
if ( image ) {
|
|
53
|
+
onChange( image );
|
|
54
|
+
}
|
|
55
|
+
setIsLoading( false );
|
|
56
|
+
},
|
|
57
|
+
onError: ( message ) => {
|
|
58
|
+
createErrorNotice( message, {
|
|
59
|
+
id: 'poster-image-upload-notice',
|
|
60
|
+
type: 'snackbar',
|
|
61
|
+
} );
|
|
62
|
+
setIsLoading( false );
|
|
63
|
+
},
|
|
64
|
+
multiple: false,
|
|
65
|
+
} );
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
const getPosterButtonContent = () => {
|
|
69
|
+
if ( ! poster && isLoading ) {
|
|
70
|
+
return <Spinner />;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
return ! poster ? __( 'Set poster image' ) : __( 'Replace' );
|
|
74
|
+
};
|
|
75
|
+
|
|
29
76
|
return (
|
|
30
77
|
<MediaUploadCheck>
|
|
31
78
|
<ToolsPanelItem
|
|
@@ -48,24 +95,19 @@ function PosterImage( { poster, onChange } ) {
|
|
|
48
95
|
__next40pxDefaultSize
|
|
49
96
|
onClick={ open }
|
|
50
97
|
aria-haspopup="dialog"
|
|
51
|
-
aria-label={
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
}
|
|
58
|
-
className={
|
|
59
|
-
poster
|
|
60
|
-
? 'block-library-poster-image__preview'
|
|
61
|
-
: 'block-library-poster-image__toggle'
|
|
62
|
-
}
|
|
98
|
+
aria-label={ __(
|
|
99
|
+
'Edit or replace the poster image.'
|
|
100
|
+
) }
|
|
101
|
+
className="block-library-poster-image__preview"
|
|
102
|
+
disabled={ isLoading }
|
|
103
|
+
accessibleWhenDisabled
|
|
63
104
|
>
|
|
64
105
|
<img
|
|
65
106
|
src={ poster }
|
|
66
107
|
alt={ __( 'Poster image preview' ) }
|
|
67
108
|
className="block-library-poster-image__preview-image"
|
|
68
109
|
/>
|
|
110
|
+
{ isLoading && <Spinner /> }
|
|
69
111
|
</Button>
|
|
70
112
|
) }
|
|
71
113
|
<HStack
|
|
@@ -87,10 +129,10 @@ function PosterImage( { poster, onChange } ) {
|
|
|
87
129
|
variant={
|
|
88
130
|
! poster ? 'secondary' : undefined
|
|
89
131
|
}
|
|
132
|
+
disabled={ isLoading }
|
|
133
|
+
accessibleWhenDisabled
|
|
90
134
|
>
|
|
91
|
-
{
|
|
92
|
-
? __( 'Set poster image' )
|
|
93
|
-
: __( 'Replace' ) }
|
|
135
|
+
{ getPosterButtonContent() }
|
|
94
136
|
</Button>
|
|
95
137
|
<p id={ descriptionId } hidden>
|
|
96
138
|
{ poster
|
|
@@ -115,11 +157,14 @@ function PosterImage( { poster, onChange } ) {
|
|
|
115
157
|
posterButtonRef.current.focus();
|
|
116
158
|
} }
|
|
117
159
|
className="block-library-poster-image__action"
|
|
160
|
+
disabled={ isLoading }
|
|
161
|
+
accessibleWhenDisabled
|
|
118
162
|
>
|
|
119
163
|
{ __( 'Remove' ) }
|
|
120
164
|
</Button>
|
|
121
165
|
) }
|
|
122
166
|
</HStack>
|
|
167
|
+
<DropZone onFilesDrop={ onDropFiles } />
|
|
123
168
|
</div>
|
|
124
169
|
) }
|
|
125
170
|
/>
|
|
@@ -13,9 +13,31 @@
|
|
|
13
13
|
opacity: 1;
|
|
14
14
|
margin-top: $grid-unit-20;
|
|
15
15
|
}
|
|
16
|
+
|
|
17
|
+
.components-drop-zone__content {
|
|
18
|
+
border-radius: $radius-small;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
// Align text and icons horizontally to avoid clipping when the poster image is not set.
|
|
22
|
+
.components-drop-zone .components-drop-zone__content-inner {
|
|
23
|
+
display: flex;
|
|
24
|
+
align-items: center;
|
|
25
|
+
gap: $grid-unit-10;
|
|
26
|
+
|
|
27
|
+
.components-drop-zone__content-icon {
|
|
28
|
+
margin: 0;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
.components-spinner {
|
|
33
|
+
position: absolute;
|
|
34
|
+
top: 50%;
|
|
35
|
+
left: 50%;
|
|
36
|
+
margin-top: -9px;
|
|
37
|
+
margin-left: -9px;
|
|
38
|
+
}
|
|
16
39
|
}
|
|
17
40
|
|
|
18
|
-
.block-library-poster-image__toggle,
|
|
19
41
|
.block-library-poster-image__preview {
|
|
20
42
|
width: 100%;
|
|
21
43
|
padding: 0;
|
|
@@ -25,9 +47,6 @@
|
|
|
25
47
|
|
|
26
48
|
display: flex;
|
|
27
49
|
justify-content: center;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
.block-library-poster-image__preview {
|
|
31
50
|
height: auto !important;
|
|
32
51
|
outline: $border-width solid rgba($black, 0.1);
|
|
33
52
|
|
|
@@ -39,18 +58,6 @@
|
|
|
39
58
|
}
|
|
40
59
|
}
|
|
41
60
|
|
|
42
|
-
.block-library-poster-image__toggle {
|
|
43
|
-
box-shadow: inset 0 0 0 $border-width $gray-400;
|
|
44
|
-
|
|
45
|
-
&:focus:not(:disabled) {
|
|
46
|
-
// Allow smooth transition between focused and unfocused box-shadow states.
|
|
47
|
-
box-shadow:
|
|
48
|
-
0 0 0 currentColor inset,
|
|
49
|
-
0 0 0 var(--wp-admin-border-width-focus)
|
|
50
|
-
var(--wp-admin-theme-color);
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
|
|
54
61
|
.block-library-poster-image__actions {
|
|
55
62
|
&:not(.block-library-poster-image__actions-select) {
|
|
56
63
|
bottom: 0;
|