@wordpress/block-library 9.10.0 → 9.11.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/README.md +10 -5
- package/build/archives/index.js +6 -0
- package/build/archives/index.js.map +1 -1
- package/build/avatar/hooks.js +2 -3
- package/build/avatar/hooks.js.map +1 -1
- package/build/button/get-updated-link-attributes.js +1 -1
- package/build/button/get-updated-link-attributes.js.map +1 -1
- package/build/comments/index.js +12 -0
- package/build/comments/index.js.map +1 -1
- package/build/cover/constants.js +8 -0
- package/build/cover/constants.js.map +1 -0
- package/build/cover/edit/index.js +24 -3
- package/build/cover/edit/index.js.map +1 -1
- package/build/cover/edit/inspector-controls.js +40 -2
- package/build/cover/edit/inspector-controls.js.map +1 -1
- package/build/cover/index.js +3 -0
- package/build/cover/index.js.map +1 -1
- package/build/cover/save.js +3 -1
- package/build/cover/save.js.map +1 -1
- package/build/file/edit.js +1 -2
- package/build/file/edit.js.map +1 -1
- package/build/gallery/constants.js +2 -1
- package/build/gallery/constants.js.map +1 -1
- package/build/gallery/edit.js +11 -2
- package/build/gallery/edit.js.map +1 -1
- package/build/gallery/utils.js +26 -5
- package/build/gallery/utils.js.map +1 -1
- package/build/html/edit.js +5 -1
- package/build/html/edit.js.map +1 -1
- package/build/html/preview.js +2 -2
- package/build/html/preview.js.map +1 -1
- package/build/latest-posts/edit.js +3 -8
- package/build/latest-posts/edit.js.map +1 -1
- package/build/navigation/edit/index.js +23 -2
- package/build/navigation/edit/index.js.map +1 -1
- package/build/navigation/edit/menu-inspector-controls.js +1 -1
- package/build/navigation/edit/menu-inspector-controls.js.map +1 -1
- package/build/navigation/edit/navigation-menu-selector.js +2 -2
- package/build/navigation/edit/navigation-menu-selector.js.map +1 -1
- package/build/paragraph/edit.js +1 -1
- package/build/paragraph/edit.js.map +1 -1
- package/build/post-featured-image/edit.js +1 -1
- package/build/post-featured-image/edit.js.map +1 -1
- package/build/post-time-to-read/edit.js +2 -2
- package/build/post-time-to-read/edit.js.map +1 -1
- package/build/query/edit/inspector-controls/order-control.js +2 -2
- package/build/query/edit/inspector-controls/order-control.js.map +1 -1
- package/build/query-title/edit.js +1 -1
- package/build/query-title/edit.js.map +1 -1
- package/build/search/edit.js +19 -14
- package/build/search/edit.js.map +1 -1
- package/build/separator/transforms.js +12 -0
- package/build/separator/transforms.js.map +1 -1
- package/build/social-links/edit.js +0 -1
- package/build/social-links/edit.js.map +1 -1
- package/build/spacer/index.js +2 -0
- package/build/spacer/index.js.map +1 -1
- package/build/spacer/transforms.js +27 -0
- package/build/spacer/transforms.js.map +1 -0
- package/build/table/edit.js +0 -1
- package/build/table/edit.js.map +1 -1
- package/build/table-of-contents/edit.js +2 -7
- package/build/table-of-contents/edit.js.map +1 -1
- package/build/template-part/edit/index.js +1 -1
- package/build/template-part/edit/index.js.map +1 -1
- package/build/video/tracks-editor.js +1 -1
- package/build/video/tracks-editor.js.map +1 -1
- package/build-module/archives/index.js +6 -0
- package/build-module/archives/index.js.map +1 -1
- package/build-module/avatar/hooks.js +2 -3
- package/build-module/avatar/hooks.js.map +1 -1
- package/build-module/button/get-updated-link-attributes.js +1 -1
- package/build-module/button/get-updated-link-attributes.js.map +1 -1
- package/build-module/comments/index.js +12 -0
- package/build-module/comments/index.js.map +1 -1
- package/build-module/cover/constants.js +2 -0
- package/build-module/cover/constants.js.map +1 -0
- package/build-module/cover/edit/index.js +24 -3
- package/build-module/cover/edit/index.js.map +1 -1
- package/build-module/cover/edit/inspector-controls.js +41 -3
- package/build-module/cover/edit/inspector-controls.js.map +1 -1
- package/build-module/cover/index.js +3 -0
- package/build-module/cover/index.js.map +1 -1
- package/build-module/cover/save.js +3 -1
- package/build-module/cover/save.js.map +1 -1
- package/build-module/file/edit.js +1 -2
- package/build-module/file/edit.js.map +1 -1
- package/build-module/gallery/constants.js +1 -0
- package/build-module/gallery/constants.js.map +1 -1
- package/build-module/gallery/edit.js +14 -5
- package/build-module/gallery/edit.js.map +1 -1
- package/build-module/gallery/utils.js +27 -6
- package/build-module/gallery/utils.js.map +1 -1
- package/build-module/html/edit.js +6 -2
- package/build-module/html/edit.js.map +1 -1
- package/build-module/html/preview.js +2 -2
- package/build-module/html/preview.js.map +1 -1
- package/build-module/latest-posts/edit.js +3 -8
- package/build-module/latest-posts/edit.js.map +1 -1
- package/build-module/navigation/edit/index.js +23 -2
- package/build-module/navigation/edit/index.js.map +1 -1
- package/build-module/navigation/edit/menu-inspector-controls.js +1 -3
- package/build-module/navigation/edit/menu-inspector-controls.js.map +1 -1
- package/build-module/navigation/edit/navigation-menu-selector.js +2 -2
- package/build-module/navigation/edit/navigation-menu-selector.js.map +1 -1
- package/build-module/paragraph/edit.js +1 -1
- package/build-module/paragraph/edit.js.map +1 -1
- package/build-module/post-featured-image/edit.js +1 -1
- package/build-module/post-featured-image/edit.js.map +1 -1
- package/build-module/post-time-to-read/edit.js +2 -2
- package/build-module/post-time-to-read/edit.js.map +1 -1
- package/build-module/query/edit/inspector-controls/order-control.js +2 -2
- package/build-module/query/edit/inspector-controls/order-control.js.map +1 -1
- package/build-module/query-title/edit.js +2 -2
- package/build-module/query-title/edit.js.map +1 -1
- package/build-module/search/edit.js +20 -15
- package/build-module/search/edit.js.map +1 -1
- package/build-module/separator/transforms.js +12 -0
- package/build-module/separator/transforms.js.map +1 -1
- package/build-module/social-links/edit.js +0 -1
- package/build-module/social-links/edit.js.map +1 -1
- package/build-module/spacer/index.js +2 -0
- package/build-module/spacer/index.js.map +1 -1
- package/build-module/spacer/transforms.js +20 -0
- package/build-module/spacer/transforms.js.map +1 -0
- package/build-module/table/edit.js +0 -1
- package/build-module/table/edit.js.map +1 -1
- package/build-module/table-of-contents/edit.js +2 -7
- package/build-module/table-of-contents/edit.js.map +1 -1
- package/build-module/template-part/edit/index.js +1 -1
- package/build-module/template-part/edit/index.js.map +1 -1
- package/build-module/video/tracks-editor.js +2 -2
- package/build-module/video/tracks-editor.js.map +1 -1
- package/build-style/archives/editor-rtl.css +5 -0
- package/build-style/archives/editor.css +5 -0
- package/build-style/button/style-rtl.css +3 -0
- package/build-style/button/style.css +3 -0
- package/build-style/comments/editor-rtl.css +4 -0
- package/build-style/comments/editor.css +4 -0
- package/build-style/comments/style-rtl.css +4 -0
- package/build-style/comments/style.css +4 -0
- package/build-style/cover/style-rtl.css +5 -0
- package/build-style/cover/style.css +5 -0
- package/build-style/editor-rtl.css +20 -0
- package/build-style/editor.css +20 -0
- package/build-style/group/editor-rtl.css +10 -0
- package/build-style/group/editor.css +10 -0
- package/build-style/image/style-rtl.css +2 -0
- package/build-style/image/style.css +2 -0
- package/build-style/navigation/editor-rtl.css +1 -0
- package/build-style/navigation/editor.css +1 -0
- package/build-style/style-rtl.css +14 -0
- package/build-style/style.css +14 -0
- package/package.json +36 -35
- package/src/archives/block.json +6 -0
- package/src/archives/editor.scss +8 -0
- package/src/avatar/hooks.js +2 -3
- package/src/avatar/index.php +4 -5
- package/src/button/get-updated-link-attributes.js +1 -1
- package/src/button/style.scss +3 -0
- package/src/button/test/get-updated-link-attributes.js +15 -0
- package/src/comment-author-avatar/index.php +1 -1
- package/src/comments/block.json +21 -3
- package/src/comments/style.scss +4 -1
- package/src/cover/block.json +3 -0
- package/src/cover/constants.js +1 -0
- package/src/cover/edit/index.js +20 -2
- package/src/cover/edit/inspector-controls.js +46 -1
- package/src/cover/save.js +2 -0
- package/src/cover/style.scss +6 -0
- package/src/cover/test/edit.js +1 -3
- package/src/file/edit.js +1 -2
- package/src/gallery/constants.js +1 -0
- package/src/gallery/edit.js +25 -2
- package/src/gallery/utils.js +23 -2
- package/src/group/editor.scss +12 -0
- package/src/html/edit.js +7 -1
- package/src/html/preview.js +3 -2
- package/src/image/style.scss +1 -0
- package/src/latest-posts/edit.js +3 -7
- package/src/latest-posts/index.php +1 -1
- package/src/navigation/edit/index.js +30 -3
- package/src/navigation/edit/menu-inspector-controls.js +2 -2
- package/src/navigation/edit/navigation-menu-selector.js +2 -2
- package/src/navigation/editor.scss +1 -0
- package/src/paragraph/edit.js +1 -1
- package/src/post-featured-image/edit.js +1 -1
- package/src/post-time-to-read/edit.js +2 -2
- package/src/post-time-to-read/index.php +1 -1
- package/src/query/edit/inspector-controls/order-control.js +2 -2
- package/src/query-title/edit.js +2 -2
- package/src/rss/index.php +1 -1
- package/src/search/edit.js +28 -25
- package/src/separator/test/__snapshots__/transforms.native.js.snap +6 -0
- package/src/separator/test/transforms.native.js +1 -1
- package/src/separator/transforms.js +11 -0
- package/src/social-links/edit.js +0 -1
- package/src/spacer/index.js +2 -0
- package/src/spacer/test/__snapshots__/transforms.native.js.snap +6 -0
- package/src/spacer/test/transforms.native.js +1 -1
- package/src/spacer/transforms.js +20 -0
- package/src/table/edit.js +0 -1
- package/src/table-of-contents/edit.js +2 -6
- package/src/template-part/edit/index.js +1 -1
- package/src/video/tracks-editor.js +2 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wordpress/block-library",
|
|
3
|
-
"version": "9.
|
|
3
|
+
"version": "9.11.0",
|
|
4
4
|
"description": "Block library for the WordPress editor.",
|
|
5
5
|
"author": "The WordPress Contributors",
|
|
6
6
|
"license": "GPL-2.0-or-later",
|
|
@@ -39,39 +39,39 @@
|
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
41
|
"@babel/runtime": "7.25.7",
|
|
42
|
-
"@wordpress/a11y": "
|
|
43
|
-
"@wordpress/api-fetch": "
|
|
44
|
-
"@wordpress/autop": "
|
|
45
|
-
"@wordpress/blob": "
|
|
46
|
-
"@wordpress/block-editor": "
|
|
47
|
-
"@wordpress/blocks": "
|
|
48
|
-
"@wordpress/components": "
|
|
49
|
-
"@wordpress/compose": "
|
|
50
|
-
"@wordpress/core-data": "
|
|
51
|
-
"@wordpress/data": "
|
|
52
|
-
"@wordpress/date": "
|
|
53
|
-
"@wordpress/deprecated": "
|
|
54
|
-
"@wordpress/dom": "
|
|
55
|
-
"@wordpress/element": "
|
|
56
|
-
"@wordpress/escape-html": "
|
|
57
|
-
"@wordpress/hooks": "
|
|
58
|
-
"@wordpress/html-entities": "
|
|
59
|
-
"@wordpress/i18n": "
|
|
60
|
-
"@wordpress/icons": "
|
|
61
|
-
"@wordpress/interactivity": "
|
|
62
|
-
"@wordpress/interactivity-router": "
|
|
63
|
-
"@wordpress/keyboard-shortcuts": "
|
|
64
|
-
"@wordpress/keycodes": "
|
|
65
|
-
"@wordpress/notices": "
|
|
66
|
-
"@wordpress/patterns": "
|
|
67
|
-
"@wordpress/primitives": "
|
|
68
|
-
"@wordpress/private-apis": "
|
|
69
|
-
"@wordpress/reusable-blocks": "
|
|
70
|
-
"@wordpress/rich-text": "
|
|
71
|
-
"@wordpress/server-side-render": "
|
|
72
|
-
"@wordpress/url": "
|
|
73
|
-
"@wordpress/viewport": "
|
|
74
|
-
"@wordpress/wordcount": "
|
|
42
|
+
"@wordpress/a11y": "*",
|
|
43
|
+
"@wordpress/api-fetch": "*",
|
|
44
|
+
"@wordpress/autop": "*",
|
|
45
|
+
"@wordpress/blob": "*",
|
|
46
|
+
"@wordpress/block-editor": "*",
|
|
47
|
+
"@wordpress/blocks": "*",
|
|
48
|
+
"@wordpress/components": "*",
|
|
49
|
+
"@wordpress/compose": "*",
|
|
50
|
+
"@wordpress/core-data": "*",
|
|
51
|
+
"@wordpress/data": "*",
|
|
52
|
+
"@wordpress/date": "*",
|
|
53
|
+
"@wordpress/deprecated": "*",
|
|
54
|
+
"@wordpress/dom": "*",
|
|
55
|
+
"@wordpress/element": "*",
|
|
56
|
+
"@wordpress/escape-html": "*",
|
|
57
|
+
"@wordpress/hooks": "*",
|
|
58
|
+
"@wordpress/html-entities": "*",
|
|
59
|
+
"@wordpress/i18n": "*",
|
|
60
|
+
"@wordpress/icons": "*",
|
|
61
|
+
"@wordpress/interactivity": "*",
|
|
62
|
+
"@wordpress/interactivity-router": "*",
|
|
63
|
+
"@wordpress/keyboard-shortcuts": "*",
|
|
64
|
+
"@wordpress/keycodes": "*",
|
|
65
|
+
"@wordpress/notices": "*",
|
|
66
|
+
"@wordpress/patterns": "*",
|
|
67
|
+
"@wordpress/primitives": "*",
|
|
68
|
+
"@wordpress/private-apis": "*",
|
|
69
|
+
"@wordpress/reusable-blocks": "*",
|
|
70
|
+
"@wordpress/rich-text": "*",
|
|
71
|
+
"@wordpress/server-side-render": "*",
|
|
72
|
+
"@wordpress/url": "*",
|
|
73
|
+
"@wordpress/viewport": "*",
|
|
74
|
+
"@wordpress/wordcount": "*",
|
|
75
75
|
"change-case": "^4.1.2",
|
|
76
76
|
"clsx": "^2.1.1",
|
|
77
77
|
"colord": "^2.7.0",
|
|
@@ -89,5 +89,6 @@
|
|
|
89
89
|
"publishConfig": {
|
|
90
90
|
"access": "public"
|
|
91
91
|
},
|
|
92
|
-
"
|
|
92
|
+
"wpScript": true,
|
|
93
|
+
"gitHead": "dcf4613b33b0eda14e203ac30f700ed0db70347f"
|
|
93
94
|
}
|
package/src/archives/block.json
CHANGED
package/src/archives/editor.scss
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
1
|
ul.wp-block-archives {
|
|
2
2
|
padding-left: 2.5em;
|
|
3
3
|
}
|
|
4
|
+
|
|
5
|
+
// The following styles are to prevent duplicate spacing and borders for the archives
|
|
6
|
+
// block in the editor given it uses server side rendering.
|
|
7
|
+
// See https://github.com/WordPress/gutenberg/pull/63400
|
|
8
|
+
.wp-block-archives .wp-block-archives {
|
|
9
|
+
margin: 0;
|
|
10
|
+
border: 0;
|
|
11
|
+
}
|
package/src/avatar/hooks.js
CHANGED
|
@@ -47,9 +47,8 @@ export function useCommentAvatar( { commentId } ) {
|
|
|
47
47
|
src: avatarUrls ? avatarUrls[ avatarUrls.length - 1 ] : defaultAvatar,
|
|
48
48
|
minSize,
|
|
49
49
|
maxSize,
|
|
50
|
-
// translators: %s is the Author name.
|
|
51
50
|
alt: authorName
|
|
52
|
-
? // translators: %s
|
|
51
|
+
? // translators: %s: Author name.
|
|
53
52
|
sprintf( __( '%s Avatar' ), authorName )
|
|
54
53
|
: __( 'Default Avatar' ),
|
|
55
54
|
};
|
|
@@ -89,7 +88,7 @@ export function useUserAvatar( { userId, postId, postType } ) {
|
|
|
89
88
|
minSize,
|
|
90
89
|
maxSize,
|
|
91
90
|
alt: authorDetails
|
|
92
|
-
? // translators: %s
|
|
91
|
+
? // translators: %s: Author name.
|
|
93
92
|
sprintf( __( '%s Avatar' ), authorDetails?.name )
|
|
94
93
|
: __( 'Default Avatar' ),
|
|
95
94
|
};
|
package/src/avatar/index.php
CHANGED
|
@@ -46,7 +46,7 @@ function render_block_core_avatar( $attributes, $content, $block ) {
|
|
|
46
46
|
}
|
|
47
47
|
|
|
48
48
|
$author_name = get_the_author_meta( 'display_name', $author_id );
|
|
49
|
-
// translators: %s
|
|
49
|
+
// translators: %s: Author name.
|
|
50
50
|
$alt = sprintf( __( '%s Avatar' ), $author_name );
|
|
51
51
|
$avatar_block = get_avatar(
|
|
52
52
|
$author_id,
|
|
@@ -64,7 +64,7 @@ function render_block_core_avatar( $attributes, $content, $block ) {
|
|
|
64
64
|
// translators: %s is the Author name.
|
|
65
65
|
$label = 'aria-label="' . esc_attr( sprintf( __( '(%s author archive, opens in a new tab)' ), $author_name ) ) . '"';
|
|
66
66
|
}
|
|
67
|
-
// translators:
|
|
67
|
+
// translators: 1: Author archive link. 2: Link target. %3$s Aria label. %4$s Avatar image.
|
|
68
68
|
$avatar_block = sprintf( '<a href="%1$s" target="%2$s" %3$s class="wp-block-avatar__link">%4$s</a>', esc_url( get_author_posts_url( $author_id ) ), esc_attr( $attributes['linkTarget'] ), $label, $avatar_block );
|
|
69
69
|
}
|
|
70
70
|
return sprintf( '<div %1s>%2s</div>', $wrapper_attributes, $avatar_block );
|
|
@@ -73,7 +73,7 @@ function render_block_core_avatar( $attributes, $content, $block ) {
|
|
|
73
73
|
if ( ! $comment ) {
|
|
74
74
|
return '';
|
|
75
75
|
}
|
|
76
|
-
/* translators: %s
|
|
76
|
+
/* translators: %s: Author name. */
|
|
77
77
|
$alt = sprintf( __( '%s Avatar' ), $comment->comment_author );
|
|
78
78
|
$avatar_block = get_avatar(
|
|
79
79
|
$comment,
|
|
@@ -88,10 +88,9 @@ function render_block_core_avatar( $attributes, $content, $block ) {
|
|
|
88
88
|
if ( isset( $attributes['isLink'] ) && $attributes['isLink'] && isset( $comment->comment_author_url ) && '' !== $comment->comment_author_url ) {
|
|
89
89
|
$label = '';
|
|
90
90
|
if ( '_blank' === $attributes['linkTarget'] ) {
|
|
91
|
-
// translators: %s
|
|
91
|
+
// translators: %s: Comment author name.
|
|
92
92
|
$label = 'aria-label="' . esc_attr( sprintf( __( '(%s website link, opens in a new tab)' ), $comment->comment_author ) ) . '"';
|
|
93
93
|
}
|
|
94
|
-
// translators: %1$s: Comment Author website link. %2$s: Link target. %3$s Aria label. %4$s Avatar image.
|
|
95
94
|
$avatar_block = sprintf( '<a href="%1$s" target="%2$s" %3$s class="wp-block-avatar__link">%4$s</a>', esc_url( $comment->comment_author_url ), esc_attr( $attributes['linkTarget'] ), $label, $avatar_block );
|
|
96
95
|
}
|
|
97
96
|
return sprintf( '<div %1s>%2s</div>', $wrapper_attributes, $avatar_block );
|
|
@@ -40,7 +40,7 @@ export function getUpdatedLinkAttributes( {
|
|
|
40
40
|
if ( nofollow ) {
|
|
41
41
|
updatedRel = updatedRel?.includes( NOFOLLOW_REL )
|
|
42
42
|
? updatedRel
|
|
43
|
-
: updatedRel + ` ${ NOFOLLOW_REL }
|
|
43
|
+
: ( updatedRel + ` ${ NOFOLLOW_REL }` ).trim();
|
|
44
44
|
} else {
|
|
45
45
|
const relRegex = new RegExp( `\\b${ NOFOLLOW_REL }\\s*`, 'g' );
|
|
46
46
|
updatedRel = updatedRel?.replace( relRegex, '' ).trim();
|
package/src/button/style.scss
CHANGED
|
@@ -9,6 +9,9 @@ $blocks-block__margin: 0.5em;
|
|
|
9
9
|
text-align: center;
|
|
10
10
|
word-break: break-word; // overflow-wrap doesn't work well if a link is wrapped in the div, so use word-break here.
|
|
11
11
|
box-sizing: border-box;
|
|
12
|
+
height: 100%;
|
|
13
|
+
width: 100%;
|
|
14
|
+
align-content: center;
|
|
12
15
|
|
|
13
16
|
&.aligncenter {
|
|
14
17
|
text-align: center;
|
|
@@ -79,6 +79,21 @@ describe( 'getUpdatedLinkAttributes method', () => {
|
|
|
79
79
|
expect( result.rel ).toEqual( 'rel_value nofollow' );
|
|
80
80
|
} );
|
|
81
81
|
|
|
82
|
+
it( 'should correctly update link attributes with nofollow without spacing', () => {
|
|
83
|
+
const options = {
|
|
84
|
+
url: 'example.com',
|
|
85
|
+
opensInNewTab: false,
|
|
86
|
+
nofollow: true,
|
|
87
|
+
rel: '',
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
const result = getUpdatedLinkAttributes( options );
|
|
91
|
+
|
|
92
|
+
expect( result.url ).toEqual( 'http://example.com' );
|
|
93
|
+
expect( result.linkTarget ).toEqual( undefined );
|
|
94
|
+
expect( result.rel ).toEqual( 'nofollow' );
|
|
95
|
+
} );
|
|
96
|
+
|
|
82
97
|
it( 'should correctly handle rel with existing nofollow values and remove duplicates', () => {
|
|
83
98
|
const options = {
|
|
84
99
|
url: 'example.com',
|
|
@@ -46,7 +46,7 @@ function render_block_core_comment_author_avatar( $attributes, $content, $block
|
|
|
46
46
|
$styles = isset( $wrapper_attributes['style'] ) ? $wrapper_attributes['style'] : '';
|
|
47
47
|
$classes = isset( $wrapper_attributes['class'] ) ? $wrapper_attributes['class'] : '';
|
|
48
48
|
|
|
49
|
-
/* translators: %s
|
|
49
|
+
/* translators: %s: Author name. */
|
|
50
50
|
$alt = sprintf( __( '%s Avatar' ), $comment->comment_author );
|
|
51
51
|
|
|
52
52
|
$avatar_block = get_avatar(
|
package/src/comments/block.json
CHANGED
|
@@ -17,7 +17,10 @@
|
|
|
17
17
|
}
|
|
18
18
|
},
|
|
19
19
|
"supports": {
|
|
20
|
-
"align": [
|
|
20
|
+
"align": [
|
|
21
|
+
"wide",
|
|
22
|
+
"full"
|
|
23
|
+
],
|
|
21
24
|
"html": false,
|
|
22
25
|
"color": {
|
|
23
26
|
"gradients": true,
|
|
@@ -45,8 +48,23 @@
|
|
|
45
48
|
"__experimentalDefaultControls": {
|
|
46
49
|
"fontSize": true
|
|
47
50
|
}
|
|
51
|
+
},
|
|
52
|
+
"__experimentalBorder": {
|
|
53
|
+
"radius": true,
|
|
54
|
+
"color": true,
|
|
55
|
+
"width": true,
|
|
56
|
+
"style": true,
|
|
57
|
+
"__experimentalDefaultControls": {
|
|
58
|
+
"radius": true,
|
|
59
|
+
"color": true,
|
|
60
|
+
"width": true,
|
|
61
|
+
"style": true
|
|
62
|
+
}
|
|
48
63
|
}
|
|
49
64
|
},
|
|
50
65
|
"editorStyle": "wp-block-comments-editor",
|
|
51
|
-
"usesContext": [
|
|
52
|
-
|
|
66
|
+
"usesContext": [
|
|
67
|
+
"postId",
|
|
68
|
+
"postType"
|
|
69
|
+
]
|
|
70
|
+
}
|
package/src/comments/style.scss
CHANGED
|
@@ -13,7 +13,6 @@
|
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
/* end utility classes */
|
|
16
|
-
|
|
17
16
|
.navigation {
|
|
18
17
|
&::after {
|
|
19
18
|
content: "";
|
|
@@ -146,3 +145,7 @@
|
|
|
146
145
|
:where(.wp-block-post-comments input[type="submit"]) {
|
|
147
146
|
border: none;
|
|
148
147
|
}
|
|
148
|
+
|
|
149
|
+
.wp-block-comments {
|
|
150
|
+
box-sizing: border-box;
|
|
151
|
+
}
|
package/src/cover/block.json
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const DEFAULT_MEDIA_SIZE_SLUG = 'full';
|
package/src/cover/edit/index.js
CHANGED
|
@@ -47,6 +47,7 @@ import {
|
|
|
47
47
|
DEFAULT_BACKGROUND_COLOR,
|
|
48
48
|
DEFAULT_OVERLAY_COLOR,
|
|
49
49
|
} from './color-utils';
|
|
50
|
+
import { DEFAULT_MEDIA_SIZE_SLUG } from '../constants';
|
|
50
51
|
|
|
51
52
|
function getInnerBlocksTemplate( attributes ) {
|
|
52
53
|
return [
|
|
@@ -100,6 +101,7 @@ function CoverEdit( {
|
|
|
100
101
|
templateLock,
|
|
101
102
|
tagName: TagName = 'div',
|
|
102
103
|
isUserOverlayColor,
|
|
104
|
+
sizeSlug,
|
|
103
105
|
} = attributes;
|
|
104
106
|
|
|
105
107
|
const [ featuredImage ] = useEntityProp(
|
|
@@ -108,6 +110,7 @@ function CoverEdit( {
|
|
|
108
110
|
'featured_media',
|
|
109
111
|
postId
|
|
110
112
|
);
|
|
113
|
+
const { getSettings } = useSelect( blockEditorStore );
|
|
111
114
|
|
|
112
115
|
const { __unstableMarkNextChangeAsNotPersistent } =
|
|
113
116
|
useDispatch( blockEditorStore );
|
|
@@ -149,8 +152,7 @@ function CoverEdit( {
|
|
|
149
152
|
isUserOverlayColor: isUserOverlayColor || false,
|
|
150
153
|
} );
|
|
151
154
|
} )();
|
|
152
|
-
//
|
|
153
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
155
|
+
// Update the block only when the featured image changes.
|
|
154
156
|
}, [ mediaUrl ] );
|
|
155
157
|
|
|
156
158
|
// instead of destructuring the attributes
|
|
@@ -199,6 +201,22 @@ function CoverEdit( {
|
|
|
199
201
|
averageBackgroundColor
|
|
200
202
|
);
|
|
201
203
|
|
|
204
|
+
if ( backgroundType === IMAGE_BACKGROUND_TYPE && mediaAttributes.id ) {
|
|
205
|
+
const { imageDefaultSize } = getSettings();
|
|
206
|
+
|
|
207
|
+
// Try to use the previous selected image size if it's available
|
|
208
|
+
// otherwise try the default image size or fallback to full size.
|
|
209
|
+
if ( sizeSlug && newMedia?.sizes?.[ sizeSlug ] ) {
|
|
210
|
+
mediaAttributes.sizeSlug = sizeSlug;
|
|
211
|
+
mediaAttributes.url = newMedia?.sizes?.[ sizeSlug ]?.url;
|
|
212
|
+
} else if ( newMedia?.sizes?.[ imageDefaultSize ] ) {
|
|
213
|
+
mediaAttributes.sizeSlug = imageDefaultSize;
|
|
214
|
+
mediaAttributes.url = newMedia?.sizes?.[ sizeSlug ]?.url;
|
|
215
|
+
} else {
|
|
216
|
+
mediaAttributes.sizeSlug = DEFAULT_MEDIA_SIZE_SLUG;
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
|
|
202
220
|
setAttributes( {
|
|
203
221
|
...mediaAttributes,
|
|
204
222
|
focalPoint: undefined,
|
|
@@ -19,12 +19,15 @@ import { useInstanceId } from '@wordpress/compose';
|
|
|
19
19
|
import {
|
|
20
20
|
InspectorControls,
|
|
21
21
|
useSettings,
|
|
22
|
+
store as blockEditorStore,
|
|
22
23
|
__experimentalColorGradientSettingsDropdown as ColorGradientSettingsDropdown,
|
|
23
24
|
__experimentalUseGradient,
|
|
24
25
|
__experimentalUseMultipleOriginColorsAndGradients as useMultipleOriginColorsAndGradients,
|
|
25
26
|
privateApis as blockEditorPrivateApis,
|
|
26
27
|
} from '@wordpress/block-editor';
|
|
27
28
|
import { __ } from '@wordpress/i18n';
|
|
29
|
+
import { useSelect } from '@wordpress/data';
|
|
30
|
+
import { store as coreStore } from '@wordpress/core-data';
|
|
28
31
|
|
|
29
32
|
/**
|
|
30
33
|
* Internal dependencies
|
|
@@ -32,8 +35,9 @@ import { __ } from '@wordpress/i18n';
|
|
|
32
35
|
import { COVER_MIN_HEIGHT, mediaPosition } from '../shared';
|
|
33
36
|
import { unlock } from '../../lock-unlock';
|
|
34
37
|
import { useToolsPanelDropdownMenuProps } from '../../utils/hooks';
|
|
38
|
+
import { DEFAULT_MEDIA_SIZE_SLUG } from '../constants';
|
|
35
39
|
|
|
36
|
-
const { cleanEmptyObject } = unlock( blockEditorPrivateApis );
|
|
40
|
+
const { cleanEmptyObject, ResolutionTool } = unlock( blockEditorPrivateApis );
|
|
37
41
|
|
|
38
42
|
function CoverHeightInput( {
|
|
39
43
|
onChange,
|
|
@@ -95,6 +99,7 @@ export default function CoverInspectorControls( {
|
|
|
95
99
|
} ) {
|
|
96
100
|
const {
|
|
97
101
|
useFeaturedImage,
|
|
102
|
+
id,
|
|
98
103
|
dimRatio,
|
|
99
104
|
focalPoint,
|
|
100
105
|
hasParallax,
|
|
@@ -112,7 +117,38 @@ export default function CoverInspectorControls( {
|
|
|
112
117
|
overlayColor,
|
|
113
118
|
} = currentSettings;
|
|
114
119
|
|
|
120
|
+
const sizeSlug = attributes.sizeSlug || DEFAULT_MEDIA_SIZE_SLUG;
|
|
121
|
+
|
|
115
122
|
const { gradientValue, setGradient } = __experimentalUseGradient();
|
|
123
|
+
const { getSettings } = useSelect( blockEditorStore );
|
|
124
|
+
|
|
125
|
+
const imageSizes = getSettings()?.imageSizes;
|
|
126
|
+
|
|
127
|
+
const image = useSelect(
|
|
128
|
+
( select ) =>
|
|
129
|
+
id && isImageBackground
|
|
130
|
+
? select( coreStore ).getMedia( id, { context: 'view' } )
|
|
131
|
+
: null,
|
|
132
|
+
[ id, isImageBackground ]
|
|
133
|
+
);
|
|
134
|
+
|
|
135
|
+
function updateImage( newSizeSlug ) {
|
|
136
|
+
const newUrl = image?.media_details?.sizes?.[ newSizeSlug ]?.source_url;
|
|
137
|
+
if ( ! newUrl ) {
|
|
138
|
+
return null;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
setAttributes( {
|
|
142
|
+
url: newUrl,
|
|
143
|
+
sizeSlug: newSizeSlug,
|
|
144
|
+
} );
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
const imageSizeOptions = imageSizes
|
|
148
|
+
?.filter(
|
|
149
|
+
( { slug } ) => image?.media_details?.sizes?.[ slug ]?.source_url
|
|
150
|
+
)
|
|
151
|
+
?.map( ( { name, slug } ) => ( { value: slug, label: name } ) );
|
|
116
152
|
|
|
117
153
|
const toggleParallax = () => {
|
|
118
154
|
setAttributes( {
|
|
@@ -175,6 +211,7 @@ export default function CoverInspectorControls( {
|
|
|
175
211
|
focalPoint: undefined,
|
|
176
212
|
isRepeated: false,
|
|
177
213
|
alt: '',
|
|
214
|
+
sizeSlug: undefined,
|
|
178
215
|
} );
|
|
179
216
|
} }
|
|
180
217
|
dropdownMenuProps={ dropdownMenuProps }
|
|
@@ -284,6 +321,14 @@ export default function CoverInspectorControls( {
|
|
|
284
321
|
/>
|
|
285
322
|
</ToolsPanelItem>
|
|
286
323
|
) }
|
|
324
|
+
{ ! useFeaturedImage && !! imageSizeOptions?.length && (
|
|
325
|
+
<ResolutionTool
|
|
326
|
+
value={ sizeSlug }
|
|
327
|
+
onChange={ updateImage }
|
|
328
|
+
options={ imageSizeOptions }
|
|
329
|
+
defaultValue={ DEFAULT_MEDIA_SIZE_SLUG }
|
|
330
|
+
/>
|
|
331
|
+
) }
|
|
287
332
|
</ToolsPanel>
|
|
288
333
|
) }
|
|
289
334
|
</InspectorControls>
|
package/src/cover/save.js
CHANGED
|
@@ -45,6 +45,7 @@ export default function save( { attributes } ) {
|
|
|
45
45
|
minHeight: minHeightProp,
|
|
46
46
|
minHeightUnit,
|
|
47
47
|
tagName: Tag,
|
|
48
|
+
sizeSlug,
|
|
48
49
|
} = attributes;
|
|
49
50
|
const overlayColorClass = getColorClassName(
|
|
50
51
|
'background-color',
|
|
@@ -95,6 +96,7 @@ export default function save( { attributes } ) {
|
|
|
95
96
|
'wp-block-cover__image-background',
|
|
96
97
|
id ? `wp-image-${ id }` : null,
|
|
97
98
|
{
|
|
99
|
+
[ `size-${ sizeSlug }` ]: sizeSlug,
|
|
98
100
|
'has-parallax': hasParallax,
|
|
99
101
|
'is-repeated': isRepeated,
|
|
100
102
|
}
|
package/src/cover/style.scss
CHANGED
|
@@ -100,6 +100,12 @@
|
|
|
100
100
|
color: inherit;
|
|
101
101
|
// Reset the fixed LTR direction at the root of the block in RTL languages.
|
|
102
102
|
/*rtl:raw: direction: rtl; */
|
|
103
|
+
|
|
104
|
+
// Reset the z-index to auto when the body has a modal open. So when the
|
|
105
|
+
// modal is inside the cover, it doesn't create a stacking context.
|
|
106
|
+
@at-root .has-modal-open & {
|
|
107
|
+
z-index: auto;
|
|
108
|
+
}
|
|
103
109
|
}
|
|
104
110
|
|
|
105
111
|
// Position: Top
|
package/src/cover/test/edit.js
CHANGED
|
@@ -119,9 +119,7 @@ describe( 'Cover block', () => {
|
|
|
119
119
|
'min-height: 100vh;'
|
|
120
120
|
);
|
|
121
121
|
|
|
122
|
-
await userEvent.click(
|
|
123
|
-
screen.getByLabelText( 'Toggle full height' )
|
|
124
|
-
);
|
|
122
|
+
await userEvent.click( screen.getByLabelText( 'Full height' ) );
|
|
125
123
|
|
|
126
124
|
expect( screen.getByLabelText( 'Block: Cover' ) ).toHaveStyle(
|
|
127
125
|
'min-height: 100vh;'
|
package/src/file/edit.js
CHANGED
|
@@ -103,8 +103,7 @@ function FileEdit( { attributes, isSelected, setAttributes, clientId } ) {
|
|
|
103
103
|
downloadButtonText: _x( 'Download', 'button label' ),
|
|
104
104
|
} );
|
|
105
105
|
}
|
|
106
|
-
//
|
|
107
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
106
|
+
// This effect should only run on mount.
|
|
108
107
|
}, [] );
|
|
109
108
|
|
|
110
109
|
function onSelectFile( newMedia ) {
|
package/src/gallery/constants.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export const LINK_DESTINATION_NONE = 'none';
|
|
2
2
|
export const LINK_DESTINATION_MEDIA = 'media';
|
|
3
|
+
export const LINK_DESTINATION_LIGHTBOX = 'lightbox';
|
|
3
4
|
export const LINK_DESTINATION_ATTACHMENT = 'attachment';
|
|
4
5
|
export const LINK_DESTINATION_MEDIA_WP_CORE = 'file';
|
|
5
6
|
export const LINK_DESTINATION_ATTACHMENT_WP_CORE = 'post';
|
package/src/gallery/edit.js
CHANGED
|
@@ -25,6 +25,7 @@ import {
|
|
|
25
25
|
useInnerBlocksProps,
|
|
26
26
|
BlockControls,
|
|
27
27
|
MediaReplaceFlow,
|
|
28
|
+
useSettings,
|
|
28
29
|
} from '@wordpress/block-editor';
|
|
29
30
|
import { Platform, useEffect, useMemo } from '@wordpress/element';
|
|
30
31
|
import { __, _x, sprintf } from '@wordpress/i18n';
|
|
@@ -38,6 +39,7 @@ import {
|
|
|
38
39
|
customLink,
|
|
39
40
|
image as imageIcon,
|
|
40
41
|
linkOff,
|
|
42
|
+
fullscreen,
|
|
41
43
|
} from '@wordpress/icons';
|
|
42
44
|
|
|
43
45
|
/**
|
|
@@ -55,6 +57,7 @@ import {
|
|
|
55
57
|
LINK_DESTINATION_ATTACHMENT,
|
|
56
58
|
LINK_DESTINATION_MEDIA,
|
|
57
59
|
LINK_DESTINATION_NONE,
|
|
60
|
+
LINK_DESTINATION_LIGHTBOX,
|
|
58
61
|
} from './constants';
|
|
59
62
|
import useImageSizes from './use-image-sizes';
|
|
60
63
|
import useGetNewImages from './use-get-new-images';
|
|
@@ -62,7 +65,7 @@ import useGetMedia from './use-get-media';
|
|
|
62
65
|
import GapStyles from './gap-styles';
|
|
63
66
|
|
|
64
67
|
const MAX_COLUMNS = 8;
|
|
65
|
-
const
|
|
68
|
+
const LINK_OPTIONS = [
|
|
66
69
|
{
|
|
67
70
|
icon: customLink,
|
|
68
71
|
label: __( 'Link images to attachment pages' ),
|
|
@@ -75,6 +78,13 @@ const linkOptions = [
|
|
|
75
78
|
value: LINK_DESTINATION_MEDIA,
|
|
76
79
|
noticeText: __( 'Media Files' ),
|
|
77
80
|
},
|
|
81
|
+
{
|
|
82
|
+
icon: fullscreen,
|
|
83
|
+
label: __( 'Expand on click' ),
|
|
84
|
+
value: LINK_DESTINATION_LIGHTBOX,
|
|
85
|
+
noticeText: __( 'Lightbox effect' ),
|
|
86
|
+
infoText: __( 'Scale images with a lightbox effect' ),
|
|
87
|
+
},
|
|
78
88
|
{
|
|
79
89
|
icon: linkOff,
|
|
80
90
|
label: _x( 'None', 'Media item link option' ),
|
|
@@ -107,6 +117,14 @@ export default function GalleryEdit( props ) {
|
|
|
107
117
|
onFocus,
|
|
108
118
|
} = props;
|
|
109
119
|
|
|
120
|
+
const [ lightboxSetting ] = useSettings( 'blocks.core/image.lightbox' );
|
|
121
|
+
|
|
122
|
+
const linkOptions = ! lightboxSetting?.allowEditing
|
|
123
|
+
? LINK_OPTIONS.filter(
|
|
124
|
+
( option ) => option.value !== LINK_DESTINATION_LIGHTBOX
|
|
125
|
+
)
|
|
126
|
+
: LINK_OPTIONS;
|
|
127
|
+
|
|
110
128
|
const { columns, imageCrop, randomOrder, linkTarget, linkTo, sizeSlug } =
|
|
111
129
|
attributes;
|
|
112
130
|
|
|
@@ -363,9 +381,13 @@ export default function GalleryEdit( props ) {
|
|
|
363
381
|
const image = block.attributes.id
|
|
364
382
|
? imageData.find( ( { id } ) => id === block.attributes.id )
|
|
365
383
|
: null;
|
|
384
|
+
|
|
366
385
|
changedAttributes[ block.clientId ] = getHrefAndDestination(
|
|
367
386
|
image,
|
|
368
|
-
value
|
|
387
|
+
value,
|
|
388
|
+
false,
|
|
389
|
+
block.attributes,
|
|
390
|
+
lightboxSetting
|
|
369
391
|
);
|
|
370
392
|
} );
|
|
371
393
|
updateBlockAttributes( blocks, changedAttributes, true );
|
|
@@ -646,6 +668,7 @@ export default function GalleryEdit( props ) {
|
|
|
646
668
|
onClose();
|
|
647
669
|
} }
|
|
648
670
|
role="menuitemradio"
|
|
671
|
+
info={ linkItem.infoText }
|
|
649
672
|
>
|
|
650
673
|
{ linkItem.label }
|
|
651
674
|
</MenuItem>
|
package/src/gallery/utils.js
CHANGED
|
@@ -7,6 +7,7 @@ import {
|
|
|
7
7
|
LINK_DESTINATION_NONE,
|
|
8
8
|
LINK_DESTINATION_MEDIA_WP_CORE,
|
|
9
9
|
LINK_DESTINATION_ATTACHMENT_WP_CORE,
|
|
10
|
+
LINK_DESTINATION_LIGHTBOX,
|
|
10
11
|
} from './constants';
|
|
11
12
|
import {
|
|
12
13
|
LINK_DESTINATION_ATTACHMENT as IMAGE_LINK_DESTINATION_ATTACHMENT,
|
|
@@ -20,13 +21,18 @@ import {
|
|
|
20
21
|
*
|
|
21
22
|
* @param {Object} image Gallery image.
|
|
22
23
|
* @param {string} galleryDestination Gallery's selected link destination.
|
|
23
|
-
* @param {Object} imageDestination Image
|
|
24
|
+
* @param {Object} imageDestination Image block link destination attribute.
|
|
25
|
+
* @param {Object} attributes Block attributes.
|
|
26
|
+
* @param {Object} lightboxSetting Lightbox setting.
|
|
27
|
+
*
|
|
24
28
|
* @return {Object} New attributes to assign to image block.
|
|
25
29
|
*/
|
|
26
30
|
export function getHrefAndDestination(
|
|
27
31
|
image,
|
|
28
32
|
galleryDestination,
|
|
29
|
-
imageDestination
|
|
33
|
+
imageDestination,
|
|
34
|
+
attributes,
|
|
35
|
+
lightboxSetting
|
|
30
36
|
) {
|
|
31
37
|
// Gutenberg and WordPress use different constants so if image_default_link_type
|
|
32
38
|
// option is set we need to map from the WP Core values.
|
|
@@ -36,17 +42,32 @@ export function getHrefAndDestination(
|
|
|
36
42
|
return {
|
|
37
43
|
href: image?.source_url || image?.url, // eslint-disable-line camelcase
|
|
38
44
|
linkDestination: IMAGE_LINK_DESTINATION_MEDIA,
|
|
45
|
+
lightbox: lightboxSetting?.enabled
|
|
46
|
+
? { ...attributes?.lightbox, enabled: false }
|
|
47
|
+
: undefined,
|
|
39
48
|
};
|
|
40
49
|
case LINK_DESTINATION_ATTACHMENT_WP_CORE:
|
|
41
50
|
case LINK_DESTINATION_ATTACHMENT:
|
|
42
51
|
return {
|
|
43
52
|
href: image?.link,
|
|
44
53
|
linkDestination: IMAGE_LINK_DESTINATION_ATTACHMENT,
|
|
54
|
+
lightbox: lightboxSetting?.enabled
|
|
55
|
+
? { ...attributes?.lightbox, enabled: false }
|
|
56
|
+
: undefined,
|
|
57
|
+
};
|
|
58
|
+
case LINK_DESTINATION_LIGHTBOX:
|
|
59
|
+
return {
|
|
60
|
+
href: undefined,
|
|
61
|
+
lightbox: ! lightboxSetting?.enabled
|
|
62
|
+
? { ...attributes?.lightbox, enabled: true }
|
|
63
|
+
: undefined,
|
|
64
|
+
linkDestination: IMAGE_LINK_DESTINATION_NONE,
|
|
45
65
|
};
|
|
46
66
|
case LINK_DESTINATION_NONE:
|
|
47
67
|
return {
|
|
48
68
|
href: undefined,
|
|
49
69
|
linkDestination: IMAGE_LINK_DESTINATION_NONE,
|
|
70
|
+
lightbox: undefined,
|
|
50
71
|
};
|
|
51
72
|
}
|
|
52
73
|
|