@wordpress/block-library 9.20.0 → 9.21.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 +3 -3
- package/build/categories/edit.js.map +1 -1
- package/build/embed/edit.js +4 -1
- package/build/embed/edit.js.map +1 -1
- package/build/image/edit.js +3 -2
- package/build/image/edit.js.map +1 -1
- package/build/image/image.js +13 -8
- package/build/image/image.js.map +1 -1
- package/build/navigation/edit/index.js +8 -4
- package/build/navigation/edit/index.js.map +1 -1
- package/build/navigation-link/edit.js +27 -8
- package/build/navigation-link/edit.js.map +1 -1
- package/build/post-featured-image/edit.js +2 -1
- package/build/post-featured-image/edit.js.map +1 -1
- package/build/query-total/index.js +3 -0
- package/build/query-total/index.js.map +1 -1
- package/build/rss/edit.js +21 -1
- package/build/rss/edit.js.map +1 -1
- package/build/rss/index.js +7 -0
- package/build/rss/index.js.map +1 -1
- package/build/site-title/edit.js +1 -1
- package/build/site-title/edit.js.map +1 -1
- package/build/table-of-contents/edit.js +50 -8
- package/build/table-of-contents/edit.js.map +1 -1
- package/build/table-of-contents/hooks.js +7 -1
- package/build/table-of-contents/hooks.js.map +1 -1
- package/build/table-of-contents/index.js +3 -0
- package/build/table-of-contents/index.js.map +1 -1
- package/build-module/categories/edit.js +3 -3
- package/build-module/categories/edit.js.map +1 -1
- package/build-module/embed/edit.js +4 -1
- package/build-module/embed/edit.js.map +1 -1
- package/build-module/image/edit.js +3 -2
- package/build-module/image/edit.js.map +1 -1
- package/build-module/image/image.js +14 -9
- package/build-module/image/image.js.map +1 -1
- package/build-module/navigation/edit/index.js +8 -4
- package/build-module/navigation/edit/index.js.map +1 -1
- package/build-module/navigation-link/edit.js +28 -9
- package/build-module/navigation-link/edit.js.map +1 -1
- package/build-module/post-featured-image/edit.js +2 -1
- package/build-module/post-featured-image/edit.js.map +1 -1
- package/build-module/query-total/index.js +3 -0
- package/build-module/query-total/index.js.map +1 -1
- package/build-module/rss/edit.js +22 -2
- package/build-module/rss/edit.js.map +1 -1
- package/build-module/rss/index.js +7 -0
- package/build-module/rss/index.js.map +1 -1
- package/build-module/site-title/edit.js +1 -1
- package/build-module/site-title/edit.js.map +1 -1
- package/build-module/table-of-contents/edit.js +52 -10
- package/build-module/table-of-contents/edit.js.map +1 -1
- package/build-module/table-of-contents/hooks.js +7 -1
- package/build-module/table-of-contents/hooks.js.map +1 -1
- package/build-module/table-of-contents/index.js +3 -0
- package/build-module/table-of-contents/index.js.map +1 -1
- package/build-style/post-comments-form/style-rtl.css +3 -0
- package/build-style/post-comments-form/style.css +3 -0
- package/build-style/style-rtl.css +3 -0
- package/build-style/style.css +3 -0
- package/package.json +35 -35
- package/src/categories/edit.js +3 -3
- package/src/embed/edit.js +7 -1
- package/src/image/edit.js +3 -3
- package/src/image/image.js +9 -12
- package/src/navigation/edit/index.js +4 -0
- package/src/navigation-link/edit.js +45 -11
- package/src/post-comments-form/style.scss +5 -0
- package/src/post-featured-image/edit.js +2 -1
- package/src/query-total/block.json +3 -0
- package/src/query-total/index.php +1 -1
- package/src/rss/block.json +7 -0
- package/src/rss/edit.js +21 -0
- package/src/rss/index.php +27 -9
- package/src/site-title/edit.js +1 -1
- package/src/site-title/index.php +1 -1
- package/src/table-of-contents/block.json +3 -0
- package/src/table-of-contents/edit.js +45 -4
- package/src/table-of-contents/hooks.js +7 -1
package/src/rss/index.php
CHANGED
|
@@ -31,6 +31,20 @@ function render_block_core_rss( $attributes ) {
|
|
|
31
31
|
|
|
32
32
|
$rss_items = $rss->get_items( 0, $attributes['itemsToShow'] );
|
|
33
33
|
$list_items = '';
|
|
34
|
+
|
|
35
|
+
$open_in_new_tab = ! empty( $attributes['openInNewTab'] );
|
|
36
|
+
$rel = ! empty( $attributes['rel'] ) ? trim( $attributes['rel'] ) : '';
|
|
37
|
+
|
|
38
|
+
$link_attributes = '';
|
|
39
|
+
|
|
40
|
+
if ( $open_in_new_tab ) {
|
|
41
|
+
$link_attributes .= ' target="_blank"';
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
if ( '' !== $rel ) {
|
|
45
|
+
$link_attributes .= ' rel="' . esc_attr( $rel ) . '"';
|
|
46
|
+
}
|
|
47
|
+
|
|
34
48
|
foreach ( $rss_items as $item ) {
|
|
35
49
|
$title = esc_html( trim( strip_tags( $item->get_title() ) ) );
|
|
36
50
|
if ( empty( $title ) ) {
|
|
@@ -38,20 +52,24 @@ function render_block_core_rss( $attributes ) {
|
|
|
38
52
|
}
|
|
39
53
|
$link = $item->get_link();
|
|
40
54
|
$link = esc_url( $link );
|
|
55
|
+
|
|
41
56
|
if ( $link ) {
|
|
42
|
-
$title = "<a href='{$link}'>{$title}</a>";
|
|
57
|
+
$title = "<a href='{$link}'{$link_attributes}>{$title}</a>";
|
|
43
58
|
}
|
|
44
59
|
$title = "<div class='wp-block-rss__item-title'>{$title}</div>";
|
|
45
60
|
|
|
46
|
-
$
|
|
47
|
-
if ( $attributes['displayDate'] ) {
|
|
48
|
-
$
|
|
61
|
+
$date_markup = '';
|
|
62
|
+
if ( ! empty( $attributes['displayDate'] ) ) {
|
|
63
|
+
$timestamp = $item->get_date( 'U' );
|
|
64
|
+
|
|
65
|
+
if ( $timestamp ) {
|
|
66
|
+
$gmt_offset = get_option( 'gmt_offset' );
|
|
67
|
+
$timestamp += (int) ( (float) $gmt_offset * HOUR_IN_SECONDS );
|
|
49
68
|
|
|
50
|
-
|
|
51
|
-
$date = sprintf(
|
|
69
|
+
$date_markup = sprintf(
|
|
52
70
|
'<time datetime="%1$s" class="wp-block-rss__item-publish-date">%2$s</time> ',
|
|
53
|
-
esc_attr( date_i18n( 'c', $
|
|
54
|
-
|
|
71
|
+
esc_attr( date_i18n( 'c', $timestamp ) ),
|
|
72
|
+
esc_html( date_i18n( get_option( 'date_format' ), $timestamp ) )
|
|
55
73
|
);
|
|
56
74
|
}
|
|
57
75
|
}
|
|
@@ -85,7 +103,7 @@ function render_block_core_rss( $attributes ) {
|
|
|
85
103
|
$excerpt = '<div class="wp-block-rss__item-excerpt">' . esc_html( $excerpt ) . '</div>';
|
|
86
104
|
}
|
|
87
105
|
|
|
88
|
-
$list_items .= "<li class='wp-block-rss__item'>{$title}{$
|
|
106
|
+
$list_items .= "<li class='wp-block-rss__item'>{$title}{$date_markup}{$author}{$excerpt}</li>";
|
|
89
107
|
}
|
|
90
108
|
|
|
91
109
|
$classnames = array();
|
package/src/site-title/edit.js
CHANGED
package/src/site-title/index.php
CHANGED
|
@@ -12,6 +12,7 @@ import { createBlock } from '@wordpress/blocks';
|
|
|
12
12
|
import {
|
|
13
13
|
Placeholder,
|
|
14
14
|
ToggleControl,
|
|
15
|
+
SelectControl,
|
|
15
16
|
ToolbarButton,
|
|
16
17
|
ToolbarGroup,
|
|
17
18
|
__experimentalToolsPanel as ToolsPanel,
|
|
@@ -39,15 +40,16 @@ import { useToolsPanelDropdownMenuProps } from '../utils/hooks';
|
|
|
39
40
|
*
|
|
40
41
|
* @param {Object} props The props.
|
|
41
42
|
* @param {Object} props.attributes The block attributes.
|
|
42
|
-
* @param {HeadingData[]} props.attributes.headings
|
|
43
|
+
* @param {HeadingData[]} props.attributes.headings The list of data for each heading in the post.
|
|
43
44
|
* @param {boolean} props.attributes.onlyIncludeCurrentPage Whether to only include headings from the current page (if the post is paginated).
|
|
44
|
-
* @param {
|
|
45
|
-
* @param {
|
|
45
|
+
* @param {number|undefined} props.attributes.maxLevel The maximum heading level to include, or null to include all levels.
|
|
46
|
+
* @param {string} props.clientId The client id.
|
|
47
|
+
* @param {(attributes: Object) => void} props.setAttributes The set attributes function.
|
|
46
48
|
*
|
|
47
49
|
* @return {Component} The component.
|
|
48
50
|
*/
|
|
49
51
|
export default function TableOfContentsEdit( {
|
|
50
|
-
attributes: { headings = [], onlyIncludeCurrentPage },
|
|
52
|
+
attributes: { headings = [], onlyIncludeCurrentPage, maxLevel },
|
|
51
53
|
clientId,
|
|
52
54
|
setAttributes,
|
|
53
55
|
} ) {
|
|
@@ -115,6 +117,7 @@ export default function TableOfContentsEdit( {
|
|
|
115
117
|
resetAll={ () => {
|
|
116
118
|
setAttributes( {
|
|
117
119
|
onlyIncludeCurrentPage: false,
|
|
120
|
+
maxLevel: undefined,
|
|
118
121
|
} );
|
|
119
122
|
} }
|
|
120
123
|
dropdownMenuProps={ dropdownMenuProps }
|
|
@@ -145,6 +148,44 @@ export default function TableOfContentsEdit( {
|
|
|
145
148
|
}
|
|
146
149
|
/>
|
|
147
150
|
</ToolsPanelItem>
|
|
151
|
+
<ToolsPanelItem
|
|
152
|
+
hasValue={ () => !! maxLevel }
|
|
153
|
+
label={ __( 'Limit heading levels' ) }
|
|
154
|
+
onDeselect={ () =>
|
|
155
|
+
setAttributes( { maxLevel: undefined } )
|
|
156
|
+
}
|
|
157
|
+
isShownByDefault
|
|
158
|
+
>
|
|
159
|
+
<SelectControl
|
|
160
|
+
__nextHasNoMarginBottom
|
|
161
|
+
__next40pxDefaultSize
|
|
162
|
+
label={ __( 'Include headings down to level' ) }
|
|
163
|
+
value={ maxLevel || '' }
|
|
164
|
+
options={ [
|
|
165
|
+
{ value: '', label: __( 'All levels' ) },
|
|
166
|
+
{ value: '1', label: __( 'Heading 1' ) },
|
|
167
|
+
{ value: '2', label: __( 'Heading 2' ) },
|
|
168
|
+
{ value: '3', label: __( 'Heading 3' ) },
|
|
169
|
+
{ value: '4', label: __( 'Heading 4' ) },
|
|
170
|
+
{ value: '5', label: __( 'Heading 5' ) },
|
|
171
|
+
{ value: '6', label: __( 'Heading 6' ) },
|
|
172
|
+
] }
|
|
173
|
+
onChange={ ( value ) =>
|
|
174
|
+
setAttributes( {
|
|
175
|
+
maxLevel: value ? parseInt( value ) : undefined,
|
|
176
|
+
} )
|
|
177
|
+
}
|
|
178
|
+
help={
|
|
179
|
+
maxLevel
|
|
180
|
+
? __(
|
|
181
|
+
'Including all heading levels in the table of contents.'
|
|
182
|
+
)
|
|
183
|
+
: __(
|
|
184
|
+
'Only include headings up to and including this level.'
|
|
185
|
+
)
|
|
186
|
+
}
|
|
187
|
+
/>
|
|
188
|
+
</ToolsPanelItem>
|
|
148
189
|
</ToolsPanel>
|
|
149
190
|
</InspectorControls>
|
|
150
191
|
);
|
|
@@ -29,7 +29,8 @@ function getLatestHeadings( select, clientId ) {
|
|
|
29
29
|
const permalink = select( 'core/editor' ).getPermalink() ?? null;
|
|
30
30
|
|
|
31
31
|
const isPaginated = getBlocksByName( 'core/nextpage' ).length !== 0;
|
|
32
|
-
const { onlyIncludeCurrentPage } =
|
|
32
|
+
const { onlyIncludeCurrentPage, maxLevel } =
|
|
33
|
+
getBlockAttributes( clientId ) ?? {};
|
|
33
34
|
|
|
34
35
|
// Get post-content block client ID.
|
|
35
36
|
const [ postContentClientId = '' ] = getBlocksByName( 'core/post-content' );
|
|
@@ -100,6 +101,11 @@ function getLatestHeadings( select, clientId ) {
|
|
|
100
101
|
if ( blockName === 'core/heading' ) {
|
|
101
102
|
const headingAttributes = getBlockAttributes( blockClientId );
|
|
102
103
|
|
|
104
|
+
// Skip headings that are deeper than maxLevel
|
|
105
|
+
if ( maxLevel && headingAttributes.level > maxLevel ) {
|
|
106
|
+
continue;
|
|
107
|
+
}
|
|
108
|
+
|
|
103
109
|
const canBeLinked =
|
|
104
110
|
typeof headingPageLink === 'string' &&
|
|
105
111
|
typeof headingAttributes.anchor === 'string' &&
|