@wordpress/block-library 9.7.1-next.5368f64a9.0 → 9.8.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/categories/edit.js +38 -17
- package/build/categories/edit.js.map +1 -1
- package/build/categories/index.js +10 -3
- package/build/categories/index.js.map +1 -1
- package/build/categories/variations.js +43 -0
- package/build/categories/variations.js.map +1 -0
- package/build/embed/edit.js +1 -0
- package/build/embed/edit.js.map +1 -1
- package/build/embed/edit.native.js +1 -0
- package/build/embed/edit.native.js.map +1 -1
- package/build/embed/embed-preview.js +80 -100
- package/build/embed/embed-preview.js.map +1 -1
- package/build/embed/embed-preview.native.js +1 -0
- package/build/embed/embed-preview.native.js.map +1 -1
- package/build/form/view.js +1 -0
- package/build/form/view.js.map +1 -1
- package/build/form-input/deprecated.js +113 -1
- package/build/form-input/deprecated.js.map +1 -1
- package/build/form-input/edit.js +16 -12
- package/build/form-input/edit.js.map +1 -1
- package/build/form-input/save.js +9 -1
- package/build/form-input/save.js.map +1 -1
- package/build/image/image.js +5 -2
- package/build/image/image.js.map +1 -1
- package/build/index.js +1 -0
- package/build/index.js.map +1 -1
- package/build/navigation-submenu/index.js +13 -0
- package/build/navigation-submenu/index.js.map +1 -1
- package/build/post-template/edit.js +6 -1
- package/build/post-template/edit.js.map +1 -1
- package/build/post-title/index.js +1 -4
- package/build/post-title/index.js.map +1 -1
- package/build/query/edit/inspector-controls/format-controls.js +102 -0
- package/build/query/edit/inspector-controls/format-controls.js.map +1 -0
- package/build/query/edit/inspector-controls/index.js +45 -9
- package/build/query/edit/inspector-controls/index.js.map +1 -1
- package/build/query/edit/query-content.js +26 -10
- package/build/query/edit/query-content.js.map +1 -1
- package/build/query/index.js +3 -1
- package/build/query/index.js.map +1 -1
- package/build/query/utils.js +12 -1
- package/build/query/utils.js.map +1 -1
- package/build/site-title/index.js +1 -4
- package/build/site-title/index.js.map +1 -1
- package/build/social-link/edit.js +13 -11
- package/build/social-link/edit.js.map +1 -1
- package/build-module/categories/edit.js +40 -19
- package/build-module/categories/edit.js.map +1 -1
- package/build-module/categories/index.js +10 -3
- package/build-module/categories/index.js.map +1 -1
- package/build-module/categories/variations.js +36 -0
- package/build-module/categories/variations.js.map +1 -0
- package/build-module/embed/edit.js +1 -0
- package/build-module/embed/edit.js.map +1 -1
- package/build-module/embed/edit.native.js +1 -0
- package/build-module/embed/edit.native.js.map +1 -1
- package/build-module/embed/embed-preview.js +80 -100
- package/build-module/embed/embed-preview.js.map +1 -1
- package/build-module/embed/embed-preview.native.js +1 -0
- package/build-module/embed/embed-preview.native.js.map +1 -1
- package/build-module/form/view.js +1 -0
- package/build-module/form/view.js.map +1 -1
- package/build-module/form-input/deprecated.js +114 -2
- package/build-module/form-input/deprecated.js.map +1 -1
- package/build-module/form-input/edit.js +16 -12
- package/build-module/form-input/edit.js.map +1 -1
- package/build-module/form-input/save.js +9 -1
- package/build-module/form-input/save.js.map +1 -1
- package/build-module/image/image.js +5 -2
- package/build-module/image/image.js.map +1 -1
- package/build-module/index.js +1 -0
- package/build-module/index.js.map +1 -1
- package/build-module/navigation-submenu/index.js +13 -0
- package/build-module/navigation-submenu/index.js.map +1 -1
- package/build-module/post-template/edit.js +6 -1
- package/build-module/post-template/edit.js.map +1 -1
- package/build-module/post-title/index.js +1 -4
- package/build-module/post-title/index.js.map +1 -1
- package/build-module/query/edit/inspector-controls/format-controls.js +96 -0
- package/build-module/query/edit/inspector-controls/format-controls.js.map +1 -0
- package/build-module/query/edit/inspector-controls/index.js +45 -9
- package/build-module/query/edit/inspector-controls/index.js.map +1 -1
- package/build-module/query/edit/query-content.js +27 -11
- package/build-module/query/edit/query-content.js.map +1 -1
- package/build-module/query/index.js +3 -1
- package/build-module/query/index.js.map +1 -1
- package/build-module/query/utils.js +12 -1
- package/build-module/query/utils.js.map +1 -1
- package/build-module/site-title/index.js +1 -4
- package/build-module/site-title/index.js.map +1 -1
- package/build-module/social-link/edit.js +14 -12
- package/build-module/social-link/edit.js.map +1 -1
- package/build-style/editor-rtl.css +1 -1
- package/build-style/editor.css +1 -1
- package/build-style/form-input/style-rtl.css +7 -8
- package/build-style/form-input/style.css +7 -8
- package/build-style/gallery/editor-rtl.css +1 -1
- package/build-style/gallery/editor.css +1 -1
- package/build-style/post-title/style-rtl.css +4 -18
- package/build-style/post-title/style.css +4 -18
- package/build-style/site-title/style-rtl.css +4 -18
- package/build-style/site-title/style.css +4 -18
- package/build-style/style-rtl.css +15 -44
- package/build-style/style.css +15 -44
- package/package.json +35 -35
- package/src/categories/block.json +7 -2
- package/src/categories/edit.js +69 -30
- package/src/categories/index.js +2 -0
- package/src/categories/index.php +21 -9
- package/src/categories/variations.js +40 -0
- package/src/comments-pagination-next/index.php +1 -1
- package/src/comments-pagination-previous/index.php +2 -1
- package/src/embed/embed-preview.js +96 -112
- package/src/form-input/deprecated.js +114 -1
- package/src/form-input/edit.js +17 -11
- package/src/form-input/save.js +13 -3
- package/src/form-input/style.scss +9 -8
- package/src/image/image.js +2 -1
- package/src/navigation-submenu/block.json +13 -0
- package/src/post-template/edit.js +6 -0
- package/src/post-template/index.php +5 -0
- package/src/post-title/block.json +1 -4
- package/src/post-title/style.scss +4 -21
- package/src/query/block.json +3 -1
- package/src/query/edit/inspector-controls/format-controls.js +90 -0
- package/src/query/edit/inspector-controls/index.js +68 -9
- package/src/query/edit/query-content.js +38 -5
- package/src/query/utils.js +16 -1
- package/src/site-title/block.json +1 -4
- package/src/site-title/style.scss +4 -21
- package/src/social-link/edit.js +11 -7
package/src/categories/index.php
CHANGED
|
@@ -21,11 +21,14 @@ function render_block_core_categories( $attributes, $content, $block ) {
|
|
|
21
21
|
static $block_id = 0;
|
|
22
22
|
++$block_id;
|
|
23
23
|
|
|
24
|
+
$taxonomy = get_taxonomy( $attributes['taxonomy'] );
|
|
25
|
+
|
|
24
26
|
$args = array(
|
|
25
27
|
'echo' => false,
|
|
26
28
|
'hierarchical' => ! empty( $attributes['showHierarchy'] ),
|
|
27
29
|
'orderby' => 'name',
|
|
28
30
|
'show_count' => ! empty( $attributes['showPostCounts'] ),
|
|
31
|
+
'taxonomy' => $attributes['taxonomy'],
|
|
29
32
|
'title_li' => '',
|
|
30
33
|
'hide_empty' => empty( $attributes['showEmpty'] ),
|
|
31
34
|
);
|
|
@@ -36,13 +39,20 @@ function render_block_core_categories( $attributes, $content, $block ) {
|
|
|
36
39
|
if ( ! empty( $attributes['displayAsDropdown'] ) ) {
|
|
37
40
|
$id = 'wp-block-categories-' . $block_id;
|
|
38
41
|
$args['id'] = $id;
|
|
39
|
-
$args['
|
|
40
|
-
$
|
|
41
|
-
$
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
42
|
+
$args['name'] = $taxonomy->query_var;
|
|
43
|
+
$args['value_field'] = 'slug';
|
|
44
|
+
$args['show_option_none'] = sprintf(
|
|
45
|
+
/* translators: %s: taxonomy's singular name */
|
|
46
|
+
__( 'Select %s' ),
|
|
47
|
+
$taxonomy->labels->singular_name
|
|
48
|
+
);
|
|
49
|
+
|
|
50
|
+
$show_label = empty( $attributes['showLabel'] ) ? ' screen-reader-text' : '';
|
|
51
|
+
$default_label = $taxonomy->label;
|
|
52
|
+
$label_text = ! empty( $attributes['label'] ) ? $attributes['label'] : $default_label;
|
|
53
|
+
$wrapper_markup = '<div %1$s><label class="wp-block-categories__label' . $show_label . '" for="' . esc_attr( $id ) . '">' . $label_text . '</label>%2$s</div>';
|
|
54
|
+
$items_markup = wp_dropdown_categories( $args );
|
|
55
|
+
$type = 'dropdown';
|
|
46
56
|
|
|
47
57
|
if ( ! is_admin() ) {
|
|
48
58
|
// Inject the dropdown script immediately after the select dropdown.
|
|
@@ -54,6 +64,8 @@ function render_block_core_categories( $attributes, $content, $block ) {
|
|
|
54
64
|
);
|
|
55
65
|
}
|
|
56
66
|
} else {
|
|
67
|
+
$args['show_option_none'] = $taxonomy->labels->no_terms;
|
|
68
|
+
|
|
57
69
|
$wrapper_markup = '<ul %1$s>%2$s</ul>';
|
|
58
70
|
$items_markup = wp_list_categories( $args );
|
|
59
71
|
$type = 'list';
|
|
@@ -92,8 +104,8 @@ function build_dropdown_script_block_core_categories( $dropdown_id ) {
|
|
|
92
104
|
( function() {
|
|
93
105
|
var dropdown = document.getElementById( '<?php echo esc_js( $dropdown_id ); ?>' );
|
|
94
106
|
function onCatChange() {
|
|
95
|
-
if ( dropdown.options[ dropdown.selectedIndex ].value
|
|
96
|
-
location.href = "<?php echo esc_url( home_url() ); ?>/?
|
|
107
|
+
if ( dropdown.options[ dropdown.selectedIndex ].value !== -1 ) {
|
|
108
|
+
location.href = "<?php echo esc_url( home_url() ); ?>/?" + dropdown.name + '=' + dropdown.options[ dropdown.selectedIndex ].value;
|
|
97
109
|
}
|
|
98
110
|
}
|
|
99
111
|
dropdown.onchange = onCatChange;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { __ } from '@wordpress/i18n';
|
|
5
|
+
import { category as icon } from '@wordpress/icons';
|
|
6
|
+
|
|
7
|
+
const variations = [
|
|
8
|
+
{
|
|
9
|
+
name: 'terms',
|
|
10
|
+
title: __( 'Terms List' ),
|
|
11
|
+
icon,
|
|
12
|
+
attributes: {
|
|
13
|
+
// We need to set an attribute here that will be set when inserting the block.
|
|
14
|
+
// We cannot leave this empty, as that would be interpreted as the default value,
|
|
15
|
+
// which is `category` -- for which we're defining a distinct variation below,
|
|
16
|
+
// for backwards compatibility reasons.
|
|
17
|
+
// The logical fallback is thus the only other built-in and public taxonomy: Tags.
|
|
18
|
+
taxonomy: 'post_tag',
|
|
19
|
+
},
|
|
20
|
+
isActive: ( blockAttributes ) =>
|
|
21
|
+
// This variation is used for any taxonomy other than `category`.
|
|
22
|
+
blockAttributes.taxonomy !== 'category',
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
name: 'categories',
|
|
26
|
+
title: __( 'Categories List' ),
|
|
27
|
+
description: __( 'Display a list of all categories.' ),
|
|
28
|
+
icon,
|
|
29
|
+
attributes: {
|
|
30
|
+
taxonomy: 'category',
|
|
31
|
+
},
|
|
32
|
+
isActive: [ 'taxonomy' ],
|
|
33
|
+
// The following is needed to prevent "Terms List" from showing up twice in the inserter
|
|
34
|
+
// (once for the block, once for the variation). Fortunately, it does not collide with
|
|
35
|
+
// `categories` being the default value of the `taxonomy` attribute.
|
|
36
|
+
isDefault: true,
|
|
37
|
+
},
|
|
38
|
+
];
|
|
39
|
+
|
|
40
|
+
export default variations;
|
|
@@ -37,7 +37,7 @@ function render_block_core_comments_pagination_next( $attributes, $content, $blo
|
|
|
37
37
|
$label .= $pagination_arrow;
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
-
$next_comments_link = get_next_comments_link( $label, $max_page );
|
|
40
|
+
$next_comments_link = get_next_comments_link( $label, $max_page, $comment_vars['paged'] ?? null );
|
|
41
41
|
|
|
42
42
|
remove_filter( 'next_posts_link_attributes', $filter_link_attributes );
|
|
43
43
|
|
|
@@ -29,7 +29,8 @@ function render_block_core_comments_pagination_previous( $attributes, $content,
|
|
|
29
29
|
};
|
|
30
30
|
add_filter( 'previous_comments_link_attributes', $filter_link_attributes );
|
|
31
31
|
|
|
32
|
-
$
|
|
32
|
+
$comment_vars = build_comment_query_vars_from_block( $block );
|
|
33
|
+
$previous_comments_link = get_previous_comments_link( $label, $comment_vars['paged'] ?? null );
|
|
33
34
|
|
|
34
35
|
remove_filter( 'previous_comments_link_attributes', $filter_link_attributes );
|
|
35
36
|
|
|
@@ -14,7 +14,7 @@ import clsx from 'clsx';
|
|
|
14
14
|
import { __, sprintf } from '@wordpress/i18n';
|
|
15
15
|
import { Placeholder, SandBox } from '@wordpress/components';
|
|
16
16
|
import { BlockIcon } from '@wordpress/block-editor';
|
|
17
|
-
import {
|
|
17
|
+
import { useState } from '@wordpress/element';
|
|
18
18
|
import { getAuthority } from '@wordpress/url';
|
|
19
19
|
|
|
20
20
|
/**
|
|
@@ -23,129 +23,113 @@ import { getAuthority } from '@wordpress/url';
|
|
|
23
23
|
import WpEmbedPreview from './wp-embed-preview';
|
|
24
24
|
import { Caption } from '../utils/caption';
|
|
25
25
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
return { interactive: false };
|
|
41
|
-
}
|
|
26
|
+
export default function EmbedPreview( {
|
|
27
|
+
preview,
|
|
28
|
+
previewable,
|
|
29
|
+
url,
|
|
30
|
+
type,
|
|
31
|
+
isSelected,
|
|
32
|
+
className,
|
|
33
|
+
icon,
|
|
34
|
+
label,
|
|
35
|
+
insertBlocksAfter,
|
|
36
|
+
attributes,
|
|
37
|
+
setAttributes,
|
|
38
|
+
} ) {
|
|
39
|
+
const [ interactive, setInteractive ] = useState( false );
|
|
42
40
|
|
|
43
|
-
|
|
41
|
+
if ( ! isSelected && interactive ) {
|
|
42
|
+
// We only want to change this when the block is not selected, because changing it when
|
|
43
|
+
// the block becomes selected makes the overlap disappear too early. Hiding the overlay
|
|
44
|
+
// happens on mouseup when the overlay is clicked.
|
|
45
|
+
setInteractive( false );
|
|
44
46
|
}
|
|
45
47
|
|
|
46
|
-
hideOverlay() {
|
|
48
|
+
const hideOverlay = () => {
|
|
47
49
|
// This is called onMouseUp on the overlay. We can't respond to the `isSelected` prop
|
|
48
50
|
// changing, because that happens on mouse down, and the overlay immediately disappears,
|
|
49
51
|
// and the mouse event can end up in the preview content. We can't use onClick on
|
|
50
52
|
// the overlay to hide it either, because then the editor misses the mouseup event, and
|
|
51
53
|
// thinks we're multi-selecting blocks.
|
|
52
|
-
|
|
53
|
-
}
|
|
54
|
+
setInteractive( true );
|
|
55
|
+
};
|
|
54
56
|
|
|
55
|
-
|
|
56
|
-
const {
|
|
57
|
-
preview,
|
|
58
|
-
previewable,
|
|
59
|
-
url,
|
|
60
|
-
type,
|
|
61
|
-
className,
|
|
62
|
-
icon,
|
|
63
|
-
label,
|
|
64
|
-
insertBlocksAfter,
|
|
65
|
-
attributes,
|
|
66
|
-
setAttributes,
|
|
67
|
-
isSelected,
|
|
68
|
-
} = this.props;
|
|
69
|
-
const { scripts } = preview;
|
|
70
|
-
const { interactive } = this.state;
|
|
57
|
+
const { scripts } = preview;
|
|
71
58
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
59
|
+
const html = 'photo' === type ? getPhotoHtml( preview ) : preview.html;
|
|
60
|
+
const embedSourceUrl = getAuthority( url );
|
|
61
|
+
const iframeTitle = sprintf(
|
|
62
|
+
// translators: %s: host providing embed content e.g: www.youtube.com
|
|
63
|
+
__( 'Embedded content from %s' ),
|
|
64
|
+
embedSourceUrl
|
|
65
|
+
);
|
|
66
|
+
const sandboxClassnames = clsx(
|
|
67
|
+
type,
|
|
68
|
+
className,
|
|
69
|
+
'wp-block-embed__wrapper'
|
|
70
|
+
);
|
|
84
71
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
72
|
+
// Disabled because the overlay div doesn't actually have a role or functionality
|
|
73
|
+
// as far as the user is concerned. We're just catching the first click so that
|
|
74
|
+
// the block can be selected without interacting with the embed preview that the overlay covers.
|
|
75
|
+
/* eslint-disable jsx-a11y/no-static-element-interactions */
|
|
76
|
+
const embedWrapper =
|
|
77
|
+
'wp-embed' === type ? (
|
|
78
|
+
<WpEmbedPreview html={ html } />
|
|
79
|
+
) : (
|
|
80
|
+
<div className="wp-block-embed__wrapper">
|
|
81
|
+
<SandBox
|
|
82
|
+
html={ html }
|
|
83
|
+
scripts={ scripts }
|
|
84
|
+
title={ iframeTitle }
|
|
85
|
+
type={ sandboxClassnames }
|
|
86
|
+
onFocus={ hideOverlay }
|
|
87
|
+
/>
|
|
88
|
+
{ ! interactive && (
|
|
89
|
+
<div
|
|
90
|
+
className="block-library-embed__interactive-overlay"
|
|
91
|
+
onMouseUp={ hideOverlay }
|
|
100
92
|
/>
|
|
101
|
-
{ ! interactive && (
|
|
102
|
-
<div
|
|
103
|
-
className="block-library-embed__interactive-overlay"
|
|
104
|
-
onMouseUp={ this.hideOverlay }
|
|
105
|
-
/>
|
|
106
|
-
) }
|
|
107
|
-
</div>
|
|
108
|
-
);
|
|
109
|
-
/* eslint-enable jsx-a11y/no-static-element-interactions */
|
|
110
|
-
|
|
111
|
-
return (
|
|
112
|
-
<figure
|
|
113
|
-
className={ clsx( className, 'wp-block-embed', {
|
|
114
|
-
'is-type-video': 'video' === type,
|
|
115
|
-
} ) }
|
|
116
|
-
>
|
|
117
|
-
{ previewable ? (
|
|
118
|
-
embedWrapper
|
|
119
|
-
) : (
|
|
120
|
-
<Placeholder
|
|
121
|
-
icon={ <BlockIcon icon={ icon } showColors /> }
|
|
122
|
-
label={ label }
|
|
123
|
-
>
|
|
124
|
-
<p className="components-placeholder__error">
|
|
125
|
-
<a href={ url }>{ url }</a>
|
|
126
|
-
</p>
|
|
127
|
-
<p className="components-placeholder__error">
|
|
128
|
-
{ sprintf(
|
|
129
|
-
/* translators: %s: host providing embed content e.g: www.youtube.com */
|
|
130
|
-
__(
|
|
131
|
-
"Embedded content from %s can't be previewed in the editor."
|
|
132
|
-
),
|
|
133
|
-
embedSourceUrl
|
|
134
|
-
) }
|
|
135
|
-
</p>
|
|
136
|
-
</Placeholder>
|
|
137
93
|
) }
|
|
138
|
-
|
|
139
|
-
attributes={ attributes }
|
|
140
|
-
setAttributes={ setAttributes }
|
|
141
|
-
isSelected={ isSelected }
|
|
142
|
-
insertBlocksAfter={ insertBlocksAfter }
|
|
143
|
-
label={ __( 'Embed caption text' ) }
|
|
144
|
-
showToolbarButton={ isSelected }
|
|
145
|
-
/>
|
|
146
|
-
</figure>
|
|
94
|
+
</div>
|
|
147
95
|
);
|
|
148
|
-
|
|
149
|
-
}
|
|
96
|
+
/* eslint-enable jsx-a11y/no-static-element-interactions */
|
|
150
97
|
|
|
151
|
-
|
|
98
|
+
return (
|
|
99
|
+
<figure
|
|
100
|
+
className={ clsx( className, 'wp-block-embed', {
|
|
101
|
+
'is-type-video': 'video' === type,
|
|
102
|
+
} ) }
|
|
103
|
+
>
|
|
104
|
+
{ previewable ? (
|
|
105
|
+
embedWrapper
|
|
106
|
+
) : (
|
|
107
|
+
<Placeholder
|
|
108
|
+
icon={ <BlockIcon icon={ icon } showColors /> }
|
|
109
|
+
label={ label }
|
|
110
|
+
>
|
|
111
|
+
<p className="components-placeholder__error">
|
|
112
|
+
<a href={ url }>{ url }</a>
|
|
113
|
+
</p>
|
|
114
|
+
<p className="components-placeholder__error">
|
|
115
|
+
{ sprintf(
|
|
116
|
+
/* translators: %s: host providing embed content e.g: www.youtube.com */
|
|
117
|
+
__(
|
|
118
|
+
"Embedded content from %s can't be previewed in the editor."
|
|
119
|
+
),
|
|
120
|
+
embedSourceUrl
|
|
121
|
+
) }
|
|
122
|
+
</p>
|
|
123
|
+
</Placeholder>
|
|
124
|
+
) }
|
|
125
|
+
<Caption
|
|
126
|
+
attributes={ attributes }
|
|
127
|
+
setAttributes={ setAttributes }
|
|
128
|
+
isSelected={ isSelected }
|
|
129
|
+
insertBlocksAfter={ insertBlocksAfter }
|
|
130
|
+
label={ __( 'Embed caption text' ) }
|
|
131
|
+
showToolbarButton={ isSelected }
|
|
132
|
+
/>
|
|
133
|
+
</figure>
|
|
134
|
+
);
|
|
135
|
+
}
|
|
@@ -9,6 +9,7 @@ import removeAccents from 'remove-accents';
|
|
|
9
9
|
*/
|
|
10
10
|
import {
|
|
11
11
|
RichText,
|
|
12
|
+
useBlockProps,
|
|
12
13
|
__experimentalGetBorderClassesAndStyles as getBorderClassesAndStyles,
|
|
13
14
|
__experimentalGetColorClassesAndStyles as getColorClassesAndStyles,
|
|
14
15
|
} from '@wordpress/block-editor';
|
|
@@ -26,6 +27,118 @@ const getNameFromLabelV1 = ( content ) => {
|
|
|
26
27
|
);
|
|
27
28
|
};
|
|
28
29
|
|
|
30
|
+
const v2 = {
|
|
31
|
+
attributes: {
|
|
32
|
+
type: {
|
|
33
|
+
type: 'string',
|
|
34
|
+
default: 'text',
|
|
35
|
+
},
|
|
36
|
+
name: {
|
|
37
|
+
type: 'string',
|
|
38
|
+
},
|
|
39
|
+
label: {
|
|
40
|
+
type: 'string',
|
|
41
|
+
default: 'Label',
|
|
42
|
+
selector: '.wp-block-form-input__label-content',
|
|
43
|
+
source: 'html',
|
|
44
|
+
__experimentalRole: 'content',
|
|
45
|
+
},
|
|
46
|
+
inlineLabel: {
|
|
47
|
+
type: 'boolean',
|
|
48
|
+
default: false,
|
|
49
|
+
},
|
|
50
|
+
required: {
|
|
51
|
+
type: 'boolean',
|
|
52
|
+
default: false,
|
|
53
|
+
selector: '.wp-block-form-input__input',
|
|
54
|
+
source: 'attribute',
|
|
55
|
+
attribute: 'required',
|
|
56
|
+
},
|
|
57
|
+
placeholder: {
|
|
58
|
+
type: 'string',
|
|
59
|
+
selector: '.wp-block-form-input__input',
|
|
60
|
+
source: 'attribute',
|
|
61
|
+
attribute: 'placeholder',
|
|
62
|
+
__experimentalRole: 'content',
|
|
63
|
+
},
|
|
64
|
+
value: {
|
|
65
|
+
type: 'string',
|
|
66
|
+
default: '',
|
|
67
|
+
selector: 'input',
|
|
68
|
+
source: 'attribute',
|
|
69
|
+
attribute: 'value',
|
|
70
|
+
},
|
|
71
|
+
visibilityPermissions: {
|
|
72
|
+
type: 'string',
|
|
73
|
+
default: 'all',
|
|
74
|
+
},
|
|
75
|
+
},
|
|
76
|
+
supports: {
|
|
77
|
+
anchor: true,
|
|
78
|
+
reusable: false,
|
|
79
|
+
spacing: {
|
|
80
|
+
margin: [ 'top', 'bottom' ],
|
|
81
|
+
},
|
|
82
|
+
__experimentalBorder: {
|
|
83
|
+
radius: true,
|
|
84
|
+
__experimentalSkipSerialization: true,
|
|
85
|
+
__experimentalDefaultControls: {
|
|
86
|
+
radius: true,
|
|
87
|
+
},
|
|
88
|
+
},
|
|
89
|
+
},
|
|
90
|
+
save( { attributes } ) {
|
|
91
|
+
const { type, name, label, inlineLabel, required, placeholder, value } =
|
|
92
|
+
attributes;
|
|
93
|
+
|
|
94
|
+
const borderProps = getBorderClassesAndStyles( attributes );
|
|
95
|
+
const colorProps = getColorClassesAndStyles( attributes );
|
|
96
|
+
|
|
97
|
+
const inputStyle = {
|
|
98
|
+
...borderProps.style,
|
|
99
|
+
...colorProps.style,
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
const inputClasses = clsx(
|
|
103
|
+
'wp-block-form-input__input',
|
|
104
|
+
colorProps.className,
|
|
105
|
+
borderProps.className
|
|
106
|
+
);
|
|
107
|
+
const TagName = type === 'textarea' ? 'textarea' : 'input';
|
|
108
|
+
|
|
109
|
+
const blockProps = useBlockProps.save();
|
|
110
|
+
|
|
111
|
+
if ( 'hidden' === type ) {
|
|
112
|
+
return <input type={ type } name={ name } value={ value } />;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
return (
|
|
116
|
+
<div { ...blockProps }>
|
|
117
|
+
{ /* eslint-disable jsx-a11y/label-has-associated-control */ }
|
|
118
|
+
<label
|
|
119
|
+
className={ clsx( 'wp-block-form-input__label', {
|
|
120
|
+
'is-label-inline': inlineLabel,
|
|
121
|
+
} ) }
|
|
122
|
+
>
|
|
123
|
+
<span className="wp-block-form-input__label-content">
|
|
124
|
+
<RichText.Content value={ label } />
|
|
125
|
+
</span>
|
|
126
|
+
<TagName
|
|
127
|
+
className={ inputClasses }
|
|
128
|
+
type={ 'textarea' === type ? undefined : type }
|
|
129
|
+
name={ name || getNameFromLabelV1( label ) }
|
|
130
|
+
required={ required }
|
|
131
|
+
aria-required={ required }
|
|
132
|
+
placeholder={ placeholder || undefined }
|
|
133
|
+
style={ inputStyle }
|
|
134
|
+
/>
|
|
135
|
+
</label>
|
|
136
|
+
{ /* eslint-enable jsx-a11y/label-has-associated-control */ }
|
|
137
|
+
</div>
|
|
138
|
+
);
|
|
139
|
+
},
|
|
140
|
+
};
|
|
141
|
+
|
|
29
142
|
// Version without wrapper div in saved markup
|
|
30
143
|
// See: https://github.com/WordPress/gutenberg/pull/56507
|
|
31
144
|
const v1 = {
|
|
@@ -137,6 +250,6 @@ const v1 = {
|
|
|
137
250
|
},
|
|
138
251
|
};
|
|
139
252
|
|
|
140
|
-
const deprecated = [ v1 ];
|
|
253
|
+
const deprecated = [ v2, v1 ];
|
|
141
254
|
|
|
142
255
|
export default deprecated;
|
package/src/form-input/edit.js
CHANGED
|
@@ -31,6 +31,9 @@ function InputFieldBlock( { attributes, setAttributes, className } ) {
|
|
|
31
31
|
ref.current.focus();
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
+
// Note: radio inputs aren't implemented yet.
|
|
35
|
+
const isCheckboxOrRadio = type === 'checkbox' || type === 'radio';
|
|
36
|
+
|
|
34
37
|
const controls = (
|
|
35
38
|
<>
|
|
36
39
|
{ 'hidden' !== type && (
|
|
@@ -81,6 +84,18 @@ function InputFieldBlock( { attributes, setAttributes, className } ) {
|
|
|
81
84
|
</>
|
|
82
85
|
);
|
|
83
86
|
|
|
87
|
+
const content = (
|
|
88
|
+
<RichText
|
|
89
|
+
tagName="span"
|
|
90
|
+
className="wp-block-form-input__label-content"
|
|
91
|
+
value={ label }
|
|
92
|
+
onChange={ ( newLabel ) => setAttributes( { label: newLabel } ) }
|
|
93
|
+
aria-label={ label ? __( 'Label' ) : __( 'Empty label' ) }
|
|
94
|
+
data-empty={ ! label }
|
|
95
|
+
placeholder={ __( 'Type the label for this input' ) }
|
|
96
|
+
/>
|
|
97
|
+
);
|
|
98
|
+
|
|
84
99
|
if ( 'hidden' === type ) {
|
|
85
100
|
return (
|
|
86
101
|
<>
|
|
@@ -111,17 +126,7 @@ function InputFieldBlock( { attributes, setAttributes, className } ) {
|
|
|
111
126
|
'is-label-inline': inlineLabel || 'checkbox' === type,
|
|
112
127
|
} ) }
|
|
113
128
|
>
|
|
114
|
-
|
|
115
|
-
tagName="span"
|
|
116
|
-
className="wp-block-form-input__label-content"
|
|
117
|
-
value={ label }
|
|
118
|
-
onChange={ ( newLabel ) =>
|
|
119
|
-
setAttributes( { label: newLabel } )
|
|
120
|
-
}
|
|
121
|
-
aria-label={ label ? __( 'Label' ) : __( 'Empty label' ) }
|
|
122
|
-
data-empty={ label ? false : true }
|
|
123
|
-
placeholder={ __( 'Type the label for this input' ) }
|
|
124
|
-
/>
|
|
129
|
+
{ ! isCheckboxOrRadio && content }
|
|
125
130
|
<TagName
|
|
126
131
|
type={ 'textarea' === type ? undefined : type }
|
|
127
132
|
className={ clsx(
|
|
@@ -147,6 +152,7 @@ function InputFieldBlock( { attributes, setAttributes, className } ) {
|
|
|
147
152
|
...colorProps.style,
|
|
148
153
|
} }
|
|
149
154
|
/>
|
|
155
|
+
{ isCheckboxOrRadio && content }
|
|
150
156
|
</span>
|
|
151
157
|
</div>
|
|
152
158
|
);
|
package/src/form-input/save.js
CHANGED
|
@@ -55,6 +55,9 @@ export default function save( { attributes } ) {
|
|
|
55
55
|
|
|
56
56
|
const blockProps = useBlockProps.save();
|
|
57
57
|
|
|
58
|
+
// Note: radio inputs aren't implemented yet.
|
|
59
|
+
const isCheckboxOrRadio = type === 'checkbox' || type === 'radio';
|
|
60
|
+
|
|
58
61
|
if ( 'hidden' === type ) {
|
|
59
62
|
return <input type={ type } name={ name } value={ value } />;
|
|
60
63
|
}
|
|
@@ -67,9 +70,11 @@ export default function save( { attributes } ) {
|
|
|
67
70
|
'is-label-inline': inlineLabel,
|
|
68
71
|
} ) }
|
|
69
72
|
>
|
|
70
|
-
|
|
71
|
-
<
|
|
72
|
-
|
|
73
|
+
{ ! isCheckboxOrRadio && (
|
|
74
|
+
<span className="wp-block-form-input__label-content">
|
|
75
|
+
<RichText.Content value={ label } />
|
|
76
|
+
</span>
|
|
77
|
+
) }
|
|
73
78
|
<TagName
|
|
74
79
|
className={ inputClasses }
|
|
75
80
|
type={ 'textarea' === type ? undefined : type }
|
|
@@ -79,6 +84,11 @@ export default function save( { attributes } ) {
|
|
|
79
84
|
placeholder={ placeholder || undefined }
|
|
80
85
|
style={ inputStyle }
|
|
81
86
|
/>
|
|
87
|
+
{ isCheckboxOrRadio && (
|
|
88
|
+
<span className="wp-block-form-input__label-content">
|
|
89
|
+
<RichText.Content value={ label } />
|
|
90
|
+
</span>
|
|
91
|
+
) }
|
|
82
92
|
</label>
|
|
83
93
|
{ /* eslint-enable jsx-a11y/label-has-associated-control */ }
|
|
84
94
|
</div>
|
|
@@ -15,16 +15,17 @@
|
|
|
15
15
|
}
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
-
/*
|
|
19
|
-
Small tweak to left-align the checkbox.
|
|
20
|
-
Even though `:has` is not currently supported in Firefox, this is a small tweak
|
|
21
|
-
and does not affect the functionality of the block or the user's experience.
|
|
22
|
-
There will be a minor inconsistency between browsers. However, it's more important to provide
|
|
23
|
-
a better experience for 80+% of users, until Firefox catches up and supports `:has`.
|
|
24
|
-
*/
|
|
25
18
|
&:has(input[type="checkbox"]) {
|
|
19
|
+
flex-direction: row;
|
|
26
20
|
width: fit-content;
|
|
27
|
-
|
|
21
|
+
|
|
22
|
+
.wp-block-form-input__label-content {
|
|
23
|
+
margin: 0;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
&:has(.wp-block-form-input__label-content + input[type="checkbox"]) {
|
|
28
|
+
/* stylelint-disable-next-line declaration-property-value-allowed-list -- This style is required for old markup. */
|
|
28
29
|
flex-direction: row-reverse;
|
|
29
30
|
}
|
|
30
31
|
}
|
package/src/image/image.js
CHANGED
|
@@ -559,7 +559,8 @@ export default function Image( {
|
|
|
559
559
|
const mediaReplaceFlow = isSingleSelected &&
|
|
560
560
|
! isEditingImage &&
|
|
561
561
|
! lockUrlControls && (
|
|
562
|
-
|
|
562
|
+
// For contentOnly mode, put this button in its own area so it has borders around it.
|
|
563
|
+
<BlockControls group={ isContentOnlyMode ? 'inline' : 'other' }>
|
|
563
564
|
<MediaReplaceFlow
|
|
564
565
|
mediaId={ id }
|
|
565
566
|
mediaURL={ url }
|
|
@@ -59,6 +59,19 @@
|
|
|
59
59
|
"supports": {
|
|
60
60
|
"reusable": false,
|
|
61
61
|
"html": false,
|
|
62
|
+
"typography": {
|
|
63
|
+
"fontSize": true,
|
|
64
|
+
"lineHeight": true,
|
|
65
|
+
"__experimentalFontFamily": true,
|
|
66
|
+
"__experimentalFontWeight": true,
|
|
67
|
+
"__experimentalFontStyle": true,
|
|
68
|
+
"__experimentalTextTransform": true,
|
|
69
|
+
"__experimentalTextDecoration": true,
|
|
70
|
+
"__experimentalLetterSpacing": true,
|
|
71
|
+
"__experimentalDefaultControls": {
|
|
72
|
+
"fontSize": true
|
|
73
|
+
}
|
|
74
|
+
},
|
|
62
75
|
"interactivity": {
|
|
63
76
|
"clientNavigation": true
|
|
64
77
|
}
|
|
@@ -90,6 +90,7 @@ export default function PostTemplateEdit( {
|
|
|
90
90
|
taxQuery,
|
|
91
91
|
parents,
|
|
92
92
|
pages,
|
|
93
|
+
format,
|
|
93
94
|
// We gather extra query args to pass to the REST API call.
|
|
94
95
|
// This way extenders of Query Loop can add their own query args,
|
|
95
96
|
// and have accurate previews in the editor.
|
|
@@ -163,6 +164,10 @@ export default function PostTemplateEdit( {
|
|
|
163
164
|
if ( parents?.length ) {
|
|
164
165
|
query.parent = parents;
|
|
165
166
|
}
|
|
167
|
+
if ( format?.length ) {
|
|
168
|
+
query.format = format;
|
|
169
|
+
}
|
|
170
|
+
|
|
166
171
|
// If sticky is not set, it will return all posts in the results.
|
|
167
172
|
// If sticky is set to `only`, it will limit the results to sticky posts only.
|
|
168
173
|
// If it is anything else, it will exclude sticky posts from results. For the record the value stored is `exclude`.
|
|
@@ -205,6 +210,7 @@ export default function PostTemplateEdit( {
|
|
|
205
210
|
templateSlug,
|
|
206
211
|
taxQuery,
|
|
207
212
|
parents,
|
|
213
|
+
format,
|
|
208
214
|
restQueryArgs,
|
|
209
215
|
previewPostType,
|
|
210
216
|
]
|
|
@@ -64,6 +64,11 @@ function render_block_core_post_template( $attributes, $content, $block ) {
|
|
|
64
64
|
if ( in_the_loop() ) {
|
|
65
65
|
$query = clone $wp_query;
|
|
66
66
|
$query->rewind_posts();
|
|
67
|
+
|
|
68
|
+
// If in a single post of any post type, default to the 'post' post type.
|
|
69
|
+
if ( is_singular() ) {
|
|
70
|
+
query_posts( array( 'post_type' => 'post' ) );
|
|
71
|
+
}
|
|
67
72
|
} else {
|
|
68
73
|
$query = $wp_query;
|
|
69
74
|
}
|