@wordpress/block-library 8.6.0 → 8.7.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/buttons/index.js +1 -0
- package/build/buttons/index.js.map +1 -1
- package/build/buttons/transforms.js +1 -0
- package/build/buttons/transforms.js.map +1 -1
- package/build/columns/edit.js +4 -2
- package/build/columns/edit.js.map +1 -1
- package/build/columns/index.js +4 -0
- package/build/columns/index.js.map +1 -1
- package/build/cover/edit/inspector-controls.js +2 -2
- package/build/cover/edit/inspector-controls.js.map +1 -1
- package/build/gallery/edit.js +8 -5
- package/build/gallery/edit.js.map +1 -1
- package/build/gallery/use-image-sizes.js +1 -1
- package/build/gallery/use-image-sizes.js.map +1 -1
- package/build/group/deprecated.js +4 -2
- package/build/group/deprecated.js.map +1 -1
- package/build/group/edit.js +22 -5
- package/build/group/edit.js.map +1 -1
- package/build/group/placeholder.js +11 -1
- package/build/group/placeholder.js.map +1 -1
- package/build/group/variations.js +23 -3
- package/build/group/variations.js.map +1 -1
- package/build/image/edit.js +1 -1
- package/build/image/edit.js.map +1 -1
- package/build/image/edit.native.js +1 -1
- package/build/image/edit.native.js.map +1 -1
- package/build/image/image.js +8 -6
- package/build/image/image.js.map +1 -1
- package/build/image/index.js +7 -2
- package/build/image/index.js.map +1 -1
- package/build/latest-posts/edit.js +1 -0
- package/build/latest-posts/edit.js.map +1 -1
- package/build/media-text/deprecated.js +228 -18
- package/build/media-text/deprecated.js.map +1 -1
- package/build/media-text/edit.js +3 -3
- package/build/media-text/edit.js.map +1 -1
- package/build/media-text/index.js +1 -1
- package/build/navigation/edit/index.js +1 -12
- package/build/navigation/edit/index.js.map +1 -1
- package/build/navigation/edit/inner-blocks.js +1 -4
- package/build/navigation/edit/inner-blocks.js.map +1 -1
- package/build/navigation/index.js +0 -1
- package/build/navigation/index.js.map +1 -1
- package/build/post-date/edit.js +2 -1
- package/build/post-date/edit.js.map +1 -1
- package/build/post-date/index.js +4 -1
- package/build/post-date/index.js.map +1 -1
- package/build/post-date/variations.js +28 -0
- package/build/post-date/variations.js.map +1 -0
- package/build/post-excerpt/edit.js +39 -10
- package/build/post-excerpt/edit.js.map +1 -1
- package/build/post-featured-image/dimension-controls.js +2 -2
- package/build/post-featured-image/dimension-controls.js.map +1 -1
- package/build/post-template/index.js +1 -1
- package/build/post-time-to-read/index.js +17 -1
- package/build/post-time-to-read/index.js.map +1 -1
- package/build/quote/index.js +1 -0
- package/build/quote/index.js.map +1 -1
- package/build/spacer/edit.js +16 -6
- package/build/spacer/edit.js.map +1 -1
- package/build-module/buttons/index.js +1 -0
- package/build-module/buttons/index.js.map +1 -1
- package/build-module/buttons/transforms.js +1 -0
- package/build-module/buttons/transforms.js.map +1 -1
- package/build-module/columns/edit.js +4 -2
- package/build-module/columns/edit.js.map +1 -1
- package/build-module/columns/index.js +4 -0
- package/build-module/columns/index.js.map +1 -1
- package/build-module/cover/edit/inspector-controls.js +2 -2
- package/build-module/cover/edit/inspector-controls.js.map +1 -1
- package/build-module/gallery/edit.js +8 -5
- package/build-module/gallery/edit.js.map +1 -1
- package/build-module/gallery/use-image-sizes.js +1 -1
- package/build-module/gallery/use-image-sizes.js.map +1 -1
- package/build-module/group/deprecated.js +4 -2
- package/build-module/group/deprecated.js.map +1 -1
- package/build-module/group/edit.js +21 -5
- package/build-module/group/edit.js.map +1 -1
- package/build-module/group/placeholder.js +11 -1
- package/build-module/group/placeholder.js.map +1 -1
- package/build-module/group/variations.js +24 -1
- package/build-module/group/variations.js.map +1 -1
- package/build-module/image/edit.js +1 -1
- package/build-module/image/edit.js.map +1 -1
- package/build-module/image/edit.native.js +1 -1
- package/build-module/image/edit.native.js.map +1 -1
- package/build-module/image/image.js +8 -6
- package/build-module/image/image.js.map +1 -1
- package/build-module/image/index.js +7 -2
- package/build-module/image/index.js.map +1 -1
- package/build-module/latest-posts/edit.js +1 -0
- package/build-module/latest-posts/edit.js.map +1 -1
- package/build-module/media-text/deprecated.js +227 -18
- package/build-module/media-text/deprecated.js.map +1 -1
- package/build-module/media-text/edit.js +3 -3
- package/build-module/media-text/edit.js.map +1 -1
- package/build-module/media-text/index.js +1 -1
- package/build-module/navigation/edit/index.js +1 -12
- package/build-module/navigation/edit/index.js.map +1 -1
- package/build-module/navigation/edit/inner-blocks.js +1 -4
- package/build-module/navigation/edit/inner-blocks.js.map +1 -1
- package/build-module/navigation/index.js +0 -1
- package/build-module/navigation/index.js.map +1 -1
- package/build-module/post-date/edit.js +2 -1
- package/build-module/post-date/edit.js.map +1 -1
- package/build-module/post-date/index.js +3 -1
- package/build-module/post-date/index.js.map +1 -1
- package/build-module/post-date/variations.js +18 -0
- package/build-module/post-date/variations.js.map +1 -0
- package/build-module/post-excerpt/edit.js +38 -11
- package/build-module/post-excerpt/edit.js.map +1 -1
- package/build-module/post-featured-image/dimension-controls.js +2 -2
- package/build-module/post-featured-image/dimension-controls.js.map +1 -1
- package/build-module/post-template/index.js +1 -1
- package/build-module/post-time-to-read/index.js +17 -1
- package/build-module/post-time-to-read/index.js.map +1 -1
- package/build-module/quote/index.js +1 -0
- package/build-module/quote/index.js.map +1 -1
- package/build-module/spacer/edit.js +16 -6
- package/build-module/spacer/edit.js.map +1 -1
- package/build-style/categories/editor-rtl.css +5 -0
- package/build-style/categories/editor.css +5 -0
- package/build-style/categories/style-rtl.css +4 -0
- package/build-style/categories/style.css +4 -0
- package/build-style/editor-rtl.css +6 -0
- package/build-style/editor.css +6 -0
- package/build-style/navigation/style-rtl.css +2 -0
- package/build-style/navigation/style.css +2 -0
- package/build-style/post-featured-image/editor-rtl.css +1 -0
- package/build-style/post-featured-image/editor.css +1 -0
- package/build-style/post-template/style-rtl.css +1 -1
- package/build-style/post-template/style.css +1 -1
- package/build-style/post-time-to-read/style-rtl.css +91 -0
- package/build-style/post-time-to-read/style.css +91 -0
- package/build-style/search/style-rtl.css +8 -7
- package/build-style/search/style.css +8 -7
- package/build-style/style-rtl.css +19 -8
- package/build-style/style.css +19 -8
- package/package.json +31 -31
- package/src/buttons/block.json +1 -0
- package/src/categories/editor.scss +5 -0
- package/src/categories/style.scss +4 -0
- package/src/columns/block.json +4 -0
- package/src/columns/edit.js +2 -1
- package/src/comments/index.php +1 -0
- package/src/cover/edit/inspector-controls.js +4 -5
- package/src/cover/test/__snapshots__/transforms.native.js.snap +2 -2
- package/src/cover/test/edit.js +324 -0
- package/src/gallery/edit.js +5 -2
- package/src/gallery/use-image-sizes.js +1 -1
- package/src/group/deprecated.js +4 -2
- package/src/group/edit.js +27 -9
- package/src/group/placeholder.js +13 -1
- package/src/group/variations.js +14 -1
- package/src/home-link/index.php +2 -2
- package/src/image/block.json +7 -2
- package/src/image/edit.js +1 -1
- package/src/image/edit.native.js +1 -1
- package/src/image/image.js +15 -7
- package/src/image/index.php +7 -2
- package/src/image/test/__snapshots__/transforms.native.js.snap +1 -1
- package/src/latest-comments/style.scss +1 -1
- package/src/latest-posts/edit.js +3 -0
- package/src/media-text/block.json +1 -1
- package/src/media-text/deprecated.js +235 -3
- package/src/media-text/edit.js +7 -6
- package/src/media-text/test/__snapshots__/transforms.native.js.snap +4 -4
- package/src/navigation/block.json +0 -1
- package/src/navigation/edit/index.js +0 -13
- package/src/navigation/edit/inner-blocks.js +0 -3
- package/src/navigation/style.scss +6 -4
- package/src/navigation-link/index.php +2 -1
- package/src/navigation-submenu/index.php +30 -76
- package/src/post-author/index.php +1 -1
- package/src/post-date/edit.js +4 -1
- package/src/post-date/index.js +2 -0
- package/src/post-date/variations.js +20 -0
- package/src/post-excerpt/edit.js +48 -16
- package/src/post-featured-image/dimension-controls.js +2 -2
- package/src/post-featured-image/editor.scss +1 -0
- package/src/post-template/block.json +1 -1
- package/src/post-template/style.scss +1 -1
- package/src/post-time-to-read/block.json +17 -1
- package/src/post-time-to-read/style.scss +4 -0
- package/src/query-title/index.php +2 -5
- package/src/quote/block.json +1 -0
- package/src/search/style.scss +16 -12
- package/src/spacer/edit.js +18 -5
- package/src/style.scss +1 -0
- package/src/video/test/__snapshots__/transforms.native.js.snap +1 -1
- package/tsconfig.tsbuildinfo +1 -1
- package/src/cover/test/block-controls.js +0 -62
|
@@ -14,66 +14,6 @@
|
|
|
14
14
|
* @param bool $is_sub_menu Whether the block is a sub-menu.
|
|
15
15
|
* @return array Colors CSS classes and inline styles.
|
|
16
16
|
*/
|
|
17
|
-
function block_core_navigation_submenu_build_css_colors( $context, $attributes, $is_sub_menu = false ) {
|
|
18
|
-
$colors = array(
|
|
19
|
-
'css_classes' => array(),
|
|
20
|
-
'inline_styles' => '',
|
|
21
|
-
);
|
|
22
|
-
|
|
23
|
-
// Text color.
|
|
24
|
-
$named_text_color = null;
|
|
25
|
-
$custom_text_color = null;
|
|
26
|
-
|
|
27
|
-
if ( $is_sub_menu && array_key_exists( 'customOverlayTextColor', $context ) ) {
|
|
28
|
-
$custom_text_color = $context['customOverlayTextColor'];
|
|
29
|
-
} elseif ( $is_sub_menu && array_key_exists( 'overlayTextColor', $context ) ) {
|
|
30
|
-
$named_text_color = $context['overlayTextColor'];
|
|
31
|
-
} elseif ( array_key_exists( 'customTextColor', $context ) ) {
|
|
32
|
-
$custom_text_color = $context['customTextColor'];
|
|
33
|
-
} elseif ( array_key_exists( 'textColor', $context ) ) {
|
|
34
|
-
$named_text_color = $context['textColor'];
|
|
35
|
-
} elseif ( isset( $context['style']['color']['text'] ) ) {
|
|
36
|
-
$custom_text_color = $context['style']['color']['text'];
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
// If has text color.
|
|
40
|
-
if ( ! is_null( $named_text_color ) ) {
|
|
41
|
-
// Add the color class.
|
|
42
|
-
array_push( $colors['css_classes'], 'has-text-color', sprintf( 'has-%s-color', $named_text_color ) );
|
|
43
|
-
} elseif ( ! is_null( $custom_text_color ) ) {
|
|
44
|
-
// Add the custom color inline style.
|
|
45
|
-
$colors['css_classes'][] = 'has-text-color';
|
|
46
|
-
$colors['inline_styles'] .= sprintf( 'color: %s;', $custom_text_color );
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
// Background color.
|
|
50
|
-
$named_background_color = null;
|
|
51
|
-
$custom_background_color = null;
|
|
52
|
-
|
|
53
|
-
if ( $is_sub_menu && array_key_exists( 'customOverlayBackgroundColor', $context ) ) {
|
|
54
|
-
$custom_background_color = $context['customOverlayBackgroundColor'];
|
|
55
|
-
} elseif ( $is_sub_menu && array_key_exists( 'overlayBackgroundColor', $context ) ) {
|
|
56
|
-
$named_background_color = $context['overlayBackgroundColor'];
|
|
57
|
-
} elseif ( array_key_exists( 'customBackgroundColor', $context ) ) {
|
|
58
|
-
$custom_background_color = $context['customBackgroundColor'];
|
|
59
|
-
} elseif ( array_key_exists( 'backgroundColor', $context ) ) {
|
|
60
|
-
$named_background_color = $context['backgroundColor'];
|
|
61
|
-
} elseif ( isset( $context['style']['color']['background'] ) ) {
|
|
62
|
-
$custom_background_color = $context['style']['color']['background'];
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
// If has background color.
|
|
66
|
-
if ( ! is_null( $named_background_color ) ) {
|
|
67
|
-
// Add the background-color class.
|
|
68
|
-
array_push( $colors['css_classes'], 'has-background', sprintf( 'has-%s-background-color', $named_background_color ) );
|
|
69
|
-
} elseif ( ! is_null( $custom_background_color ) ) {
|
|
70
|
-
// Add the custom background-color inline style.
|
|
71
|
-
$colors['css_classes'][] = 'has-background';
|
|
72
|
-
$colors['inline_styles'] .= sprintf( 'background-color: %s;', $custom_background_color );
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
return $colors;
|
|
76
|
-
}
|
|
77
17
|
|
|
78
18
|
/**
|
|
79
19
|
* Build an array with CSS classes and inline styles defining the font sizes
|
|
@@ -129,7 +69,6 @@ function block_core_navigation_submenu_render_submenu_icon() {
|
|
|
129
69
|
* @return string Returns the post content with the legacy widget added.
|
|
130
70
|
*/
|
|
131
71
|
function render_block_core_navigation_submenu( $attributes, $content, $block ) {
|
|
132
|
-
|
|
133
72
|
$navigation_link_has_id = isset( $attributes['id'] ) && is_numeric( $attributes['id'] );
|
|
134
73
|
$is_post_type = isset( $attributes['kind'] ) && 'post-type' === $attributes['kind'];
|
|
135
74
|
$is_post_type = $is_post_type || isset( $attributes['type'] ) && ( 'post' === $attributes['type'] || 'page' === $attributes['type'] );
|
|
@@ -144,17 +83,13 @@ function render_block_core_navigation_submenu( $attributes, $content, $block ) {
|
|
|
144
83
|
return '';
|
|
145
84
|
}
|
|
146
85
|
|
|
147
|
-
$colors = block_core_navigation_submenu_build_css_colors( $block->context, $attributes );
|
|
148
86
|
$font_sizes = block_core_navigation_submenu_build_css_font_sizes( $block->context );
|
|
149
|
-
$
|
|
150
|
-
$colors['css_classes'],
|
|
151
|
-
$font_sizes['css_classes']
|
|
152
|
-
);
|
|
153
|
-
$style_attribute = ( $colors['inline_styles'] . $font_sizes['inline_styles'] );
|
|
87
|
+
$style_attribute = $font_sizes['inline_styles'];
|
|
154
88
|
|
|
155
|
-
$css_classes = trim( implode( ' ', $
|
|
89
|
+
$css_classes = trim( implode( ' ', $font_sizes['css_classes'] ) );
|
|
156
90
|
$has_submenu = count( $block->inner_blocks ) > 0;
|
|
157
|
-
$
|
|
91
|
+
$kind = empty( $attributes['kind'] ) ? 'post_type' : str_replace( '-', '_', $attributes['kind'] );
|
|
92
|
+
$is_active = ! empty( $attributes['id'] ) && get_queried_object_id() === (int) $attributes['id'] && ! empty( get_queried_object()->$kind );
|
|
158
93
|
|
|
159
94
|
$show_submenu_indicators = isset( $block->context['showSubmenuIcon'] ) && $block->context['showSubmenuIcon'];
|
|
160
95
|
$open_on_click = isset( $block->context['openSubmenusOnClick'] ) && $block->context['openSubmenusOnClick'];
|
|
@@ -249,14 +184,33 @@ function render_block_core_navigation_submenu( $attributes, $content, $block ) {
|
|
|
249
184
|
}
|
|
250
185
|
|
|
251
186
|
if ( $has_submenu ) {
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
$
|
|
256
|
-
|
|
257
|
-
|
|
187
|
+
// Copy some attributes from the parent block to this one.
|
|
188
|
+
// Ideally this would happen in the client when the block is created.
|
|
189
|
+
if ( array_key_exists( 'overlayTextColor', $block->context ) ) {
|
|
190
|
+
$attributes['textColor'] = $block->context['overlayTextColor'];
|
|
191
|
+
}
|
|
192
|
+
if ( array_key_exists( 'overlayBackgroundColor', $block->context ) ) {
|
|
193
|
+
$attributes['backgroundColor'] = $block->context['overlayBackgroundColor'];
|
|
194
|
+
}
|
|
195
|
+
if ( array_key_exists( 'customOverlayTextColor', $block->context ) ) {
|
|
196
|
+
$attributes['style']['color']['text'] = $block->context['customOverlayTextColor'];
|
|
197
|
+
}
|
|
198
|
+
if ( array_key_exists( 'customOverlayBackgroundColor', $block->context ) ) {
|
|
199
|
+
$attributes['style']['color']['background'] = $block->context['customOverlayBackgroundColor'];
|
|
200
|
+
}
|
|
258
201
|
|
|
259
|
-
|
|
202
|
+
// This allows us to be able to get a response from gutenberg_apply_colors_support.
|
|
203
|
+
$block->block_type->supports['color'] = true;
|
|
204
|
+
$colors_supports = gutenberg_apply_colors_support( $block->block_type, $attributes );
|
|
205
|
+
$css_classes = 'wp-block-navigation__submenu-container';
|
|
206
|
+
if ( array_key_exists( 'class', $colors_supports ) ) {
|
|
207
|
+
$css_classes .= ' ' . $colors_supports['class'];
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
$style_attribute = '';
|
|
211
|
+
if ( array_key_exists( 'style', $colors_supports ) ) {
|
|
212
|
+
$style_attribute = $colors_supports['style'];
|
|
213
|
+
}
|
|
260
214
|
|
|
261
215
|
$inner_blocks_html = '';
|
|
262
216
|
foreach ( $block->inner_blocks as $inner_block ) {
|
|
@@ -32,7 +32,7 @@ function render_block_core_post_author( $attributes, $content, $block ) {
|
|
|
32
32
|
$link = get_author_posts_url( $author_id );
|
|
33
33
|
$author_name = get_the_author_meta( 'display_name', $author_id );
|
|
34
34
|
if ( ! empty( $attributes['isLink'] && ! empty( $attributes['linkTarget'] ) ) ) {
|
|
35
|
-
$author_name = sprintf( '<a href="%
|
|
35
|
+
$author_name = sprintf( '<a href="%1$s" target="%2$s">%3$s</a>', esc_url( $link ), esc_attr( $attributes['linkTarget'] ), $author_name );
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
$byline = ! empty( $attributes['byline'] ) ? $attributes['byline'] : false;
|
package/src/post-date/edit.js
CHANGED
|
@@ -76,12 +76,15 @@ export default function PostDateEdit( {
|
|
|
76
76
|
[ postTypeSlug ]
|
|
77
77
|
);
|
|
78
78
|
|
|
79
|
+
const dateLabel =
|
|
80
|
+
displayType === 'date' ? __( 'Post Date' ) : __( 'Post Modified Date' );
|
|
81
|
+
|
|
79
82
|
let postDate = date ? (
|
|
80
83
|
<time dateTime={ dateI18n( 'c', date ) } ref={ setPopoverAnchor }>
|
|
81
84
|
{ dateI18n( format || siteFormat, date ) }
|
|
82
85
|
</time>
|
|
83
86
|
) : (
|
|
84
|
-
|
|
87
|
+
dateLabel
|
|
85
88
|
);
|
|
86
89
|
|
|
87
90
|
if ( isLink && date ) {
|
package/src/post-date/index.js
CHANGED
|
@@ -10,6 +10,7 @@ import initBlock from '../utils/init-block';
|
|
|
10
10
|
import metadata from './block.json';
|
|
11
11
|
import edit from './edit';
|
|
12
12
|
import deprecated from './deprecated';
|
|
13
|
+
import variations from './variations';
|
|
13
14
|
|
|
14
15
|
const { name } = metadata;
|
|
15
16
|
export { metadata, name };
|
|
@@ -18,6 +19,7 @@ export const settings = {
|
|
|
18
19
|
icon,
|
|
19
20
|
edit,
|
|
20
21
|
deprecated,
|
|
22
|
+
variations,
|
|
21
23
|
};
|
|
22
24
|
|
|
23
25
|
export const init = () => initBlock( { name, metadata, settings } );
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { __ } from '@wordpress/i18n';
|
|
5
|
+
import { postDate } from '@wordpress/icons';
|
|
6
|
+
|
|
7
|
+
const variations = [
|
|
8
|
+
{
|
|
9
|
+
name: 'post-date-modified',
|
|
10
|
+
title: __( 'Post Modified Date' ),
|
|
11
|
+
description: __( "Display a post's last updated date." ),
|
|
12
|
+
attributes: { displayType: 'modified' },
|
|
13
|
+
scope: [ 'block', 'inserter' ],
|
|
14
|
+
isActive: ( blockAttributes ) =>
|
|
15
|
+
blockAttributes.displayType === 'modified',
|
|
16
|
+
icon: postDate,
|
|
17
|
+
},
|
|
18
|
+
];
|
|
19
|
+
|
|
20
|
+
export default variations;
|
package/src/post-excerpt/edit.js
CHANGED
|
@@ -6,7 +6,7 @@ import classnames from 'classnames';
|
|
|
6
6
|
/**
|
|
7
7
|
* WordPress dependencies
|
|
8
8
|
*/
|
|
9
|
-
import { useEntityProp } from '@wordpress/core-data';
|
|
9
|
+
import { useEntityProp, store as coreStore } from '@wordpress/core-data';
|
|
10
10
|
import { useMemo } from '@wordpress/element';
|
|
11
11
|
import {
|
|
12
12
|
AlignmentToolbar,
|
|
@@ -18,12 +18,15 @@ import {
|
|
|
18
18
|
} from '@wordpress/block-editor';
|
|
19
19
|
import { PanelBody, ToggleControl, RangeControl } from '@wordpress/components';
|
|
20
20
|
import { __, _x } from '@wordpress/i18n';
|
|
21
|
+
import { useSelect } from '@wordpress/data';
|
|
21
22
|
|
|
22
23
|
/**
|
|
23
24
|
* Internal dependencies
|
|
24
25
|
*/
|
|
25
26
|
import { useCanEditEntity } from '../utils/hooks';
|
|
26
27
|
|
|
28
|
+
const ELLIPSIS = '…';
|
|
29
|
+
|
|
27
30
|
export default function PostExcerptEditor( {
|
|
28
31
|
attributes: { textAlign, moreText, showMoreOnNewLine, excerptLength },
|
|
29
32
|
setAttributes,
|
|
@@ -32,13 +35,41 @@ export default function PostExcerptEditor( {
|
|
|
32
35
|
} ) {
|
|
33
36
|
const isDescendentOfQueryLoop = Number.isFinite( queryId );
|
|
34
37
|
const userCanEdit = useCanEditEntity( 'postType', postType, postId );
|
|
35
|
-
const isEditable = userCanEdit && ! isDescendentOfQueryLoop;
|
|
36
|
-
|
|
37
38
|
const [
|
|
38
39
|
rawExcerpt,
|
|
39
40
|
setExcerpt,
|
|
40
41
|
{ rendered: renderedExcerpt, protected: isProtected } = {},
|
|
41
42
|
] = useEntityProp( 'postType', postType, 'excerpt', postId );
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Check if the post type supports excerpts.
|
|
46
|
+
* Add an exception and return early for the "page" post type,
|
|
47
|
+
* which is registered without support for the excerpt UI,
|
|
48
|
+
* but supports saving the excerpt to the database.
|
|
49
|
+
* See: https://core.trac.wordpress.org/browser/branches/6.1/src/wp-includes/post.php#L65
|
|
50
|
+
* Without this exception, users that have excerpts saved to the database will
|
|
51
|
+
* not be able to edit the excerpts.
|
|
52
|
+
*/
|
|
53
|
+
const postTypeSupportsExcerpts = useSelect(
|
|
54
|
+
( select ) => {
|
|
55
|
+
if ( postType === 'page' ) {
|
|
56
|
+
return true;
|
|
57
|
+
}
|
|
58
|
+
return !! select( coreStore ).getPostType( postType )?.supports
|
|
59
|
+
.excerpt;
|
|
60
|
+
},
|
|
61
|
+
[ postType ]
|
|
62
|
+
);
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* The excerpt is editable if:
|
|
66
|
+
* - The user can edit the post
|
|
67
|
+
* - It is not a descendent of a Query Loop block
|
|
68
|
+
* - The post type supports excerpts
|
|
69
|
+
*/
|
|
70
|
+
const isEditable =
|
|
71
|
+
userCanEdit && ! isDescendentOfQueryLoop && postTypeSupportsExcerpts;
|
|
72
|
+
|
|
42
73
|
const blockProps = useBlockProps( {
|
|
43
74
|
className: classnames( {
|
|
44
75
|
[ `has-text-align-${ textAlign }` ]: textAlign,
|
|
@@ -65,6 +96,7 @@ export default function PostExcerptEditor( {
|
|
|
65
96
|
);
|
|
66
97
|
return document.body.textContent || document.body.innerText || '';
|
|
67
98
|
}, [ renderedExcerpt ] );
|
|
99
|
+
|
|
68
100
|
if ( ! postType || ! postId ) {
|
|
69
101
|
return (
|
|
70
102
|
<>
|
|
@@ -123,14 +155,13 @@ export default function PostExcerptEditor( {
|
|
|
123
155
|
* The excerpt length setting needs to be applied to both
|
|
124
156
|
* the raw and the rendered excerpt depending on which is being used.
|
|
125
157
|
*/
|
|
126
|
-
const rawOrRenderedExcerpt =
|
|
127
|
-
|
|
128
|
-
|
|
158
|
+
const rawOrRenderedExcerpt = (
|
|
159
|
+
rawExcerpt || strippedRenderedExcerpt
|
|
160
|
+
).trim();
|
|
129
161
|
|
|
130
162
|
let trimmedExcerpt = '';
|
|
131
163
|
if ( wordCountType === 'words' ) {
|
|
132
164
|
trimmedExcerpt = rawOrRenderedExcerpt
|
|
133
|
-
.trim()
|
|
134
165
|
.split( ' ', excerptLength )
|
|
135
166
|
.join( ' ' );
|
|
136
167
|
} else if ( wordCountType === 'characters_excluding_spaces' ) {
|
|
@@ -143,7 +174,6 @@ export default function PostExcerptEditor( {
|
|
|
143
174
|
* so that the spaces are excluded from the word count.
|
|
144
175
|
*/
|
|
145
176
|
const excerptWithSpaces = rawOrRenderedExcerpt
|
|
146
|
-
.trim()
|
|
147
177
|
.split( '', excerptLength )
|
|
148
178
|
.join( '' );
|
|
149
179
|
|
|
@@ -152,14 +182,15 @@ export default function PostExcerptEditor( {
|
|
|
152
182
|
excerptWithSpaces.replaceAll( ' ', '' ).length;
|
|
153
183
|
|
|
154
184
|
trimmedExcerpt = rawOrRenderedExcerpt
|
|
155
|
-
.trim()
|
|
156
185
|
.split( '', excerptLength + numberOfSpaces )
|
|
157
186
|
.join( '' );
|
|
158
187
|
} else if ( wordCountType === 'characters_including_spaces' ) {
|
|
159
|
-
trimmedExcerpt = rawOrRenderedExcerpt
|
|
188
|
+
trimmedExcerpt = rawOrRenderedExcerpt
|
|
189
|
+
.split( '', excerptLength )
|
|
190
|
+
.join( '' );
|
|
160
191
|
}
|
|
161
192
|
|
|
162
|
-
|
|
193
|
+
const isTrimmed = trimmedExcerpt !== rawOrRenderedExcerpt;
|
|
163
194
|
|
|
164
195
|
const excerptContent = isEditable ? (
|
|
165
196
|
<RichText
|
|
@@ -168,7 +199,9 @@ export default function PostExcerptEditor( {
|
|
|
168
199
|
value={
|
|
169
200
|
isSelected
|
|
170
201
|
? rawOrRenderedExcerpt
|
|
171
|
-
: (
|
|
202
|
+
: ( ! isTrimmed
|
|
203
|
+
? rawOrRenderedExcerpt
|
|
204
|
+
: trimmedExcerpt + ELLIPSIS ) ||
|
|
172
205
|
__( 'No post excerpt found' )
|
|
173
206
|
}
|
|
174
207
|
onChange={ setExcerpt }
|
|
@@ -176,9 +209,9 @@ export default function PostExcerptEditor( {
|
|
|
176
209
|
/>
|
|
177
210
|
) : (
|
|
178
211
|
<p className={ excerptClassName }>
|
|
179
|
-
{
|
|
180
|
-
?
|
|
181
|
-
:
|
|
212
|
+
{ ! isTrimmed
|
|
213
|
+
? rawOrRenderedExcerpt || __( 'No post excerpt found' )
|
|
214
|
+
: trimmedExcerpt + ELLIPSIS }
|
|
182
215
|
</p>
|
|
183
216
|
);
|
|
184
217
|
return (
|
|
@@ -208,7 +241,6 @@ export default function PostExcerptEditor( {
|
|
|
208
241
|
value={ excerptLength }
|
|
209
242
|
onChange={ ( value ) => {
|
|
210
243
|
setAttributes( { excerptLength: value } );
|
|
211
|
-
setExcerpt();
|
|
212
244
|
} }
|
|
213
245
|
min="10"
|
|
214
246
|
max="100"
|
|
@@ -204,7 +204,7 @@ const DimensionControls = ( {
|
|
|
204
204
|
{ !! imageSizeOptions.length && (
|
|
205
205
|
<ToolsPanelItem
|
|
206
206
|
hasValue={ () => !! sizeSlug }
|
|
207
|
-
label={ __( '
|
|
207
|
+
label={ __( 'Resolution' ) }
|
|
208
208
|
onDeselect={ () =>
|
|
209
209
|
setAttributes( { sizeSlug: undefined } )
|
|
210
210
|
}
|
|
@@ -216,7 +216,7 @@ const DimensionControls = ( {
|
|
|
216
216
|
>
|
|
217
217
|
<SelectControl
|
|
218
218
|
__nextHasNoMarginBottom
|
|
219
|
-
label={ __( '
|
|
219
|
+
label={ __( 'Resolution' ) }
|
|
220
220
|
value={ sizeSlug || DEFAULT_SIZE }
|
|
221
221
|
options={ imageSizeOptions }
|
|
222
222
|
onChange={ ( nextSizeSlug ) =>
|
|
@@ -15,6 +15,22 @@
|
|
|
15
15
|
},
|
|
16
16
|
"supports": {
|
|
17
17
|
"html": false,
|
|
18
|
-
"
|
|
18
|
+
"spacing": {
|
|
19
|
+
"margin": true,
|
|
20
|
+
"padding": true
|
|
21
|
+
},
|
|
22
|
+
"typography": {
|
|
23
|
+
"fontSize": true,
|
|
24
|
+
"lineHeight": true,
|
|
25
|
+
"__experimentalFontFamily": true,
|
|
26
|
+
"__experimentalFontWeight": true,
|
|
27
|
+
"__experimentalFontStyle": true,
|
|
28
|
+
"__experimentalTextTransform": true,
|
|
29
|
+
"__experimentalTextDecoration": true,
|
|
30
|
+
"__experimentalLetterSpacing": true,
|
|
31
|
+
"__experimentalDefaultControls": {
|
|
32
|
+
"fontSize": true
|
|
33
|
+
}
|
|
34
|
+
}
|
|
19
35
|
}
|
|
20
36
|
}
|
|
@@ -28,12 +28,9 @@ function render_block_core_query_title( $attributes ) {
|
|
|
28
28
|
if ( $is_archive ) {
|
|
29
29
|
$show_prefix = isset( $attributes['showPrefix'] ) ? $attributes['showPrefix'] : true;
|
|
30
30
|
if ( ! $show_prefix ) {
|
|
31
|
-
|
|
32
|
-
return $original_title;
|
|
33
|
-
};
|
|
34
|
-
add_filter( 'get_the_archive_title', $filter_title, 10, 2 );
|
|
31
|
+
add_filter( 'get_the_archive_title_prefix', '__return_empty_string', 1 );
|
|
35
32
|
$title = get_the_archive_title();
|
|
36
|
-
remove_filter( '
|
|
33
|
+
remove_filter( 'get_the_archive_title_prefix', '__return_empty_string', 1 );
|
|
37
34
|
} else {
|
|
38
35
|
$title = get_the_archive_title();
|
|
39
36
|
}
|
package/src/quote/block.json
CHANGED
package/src/search/style.scss
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
|
+
$button-spacing-x: $grid-unit-10 + math.div($grid-unit-05, 2); // 10px
|
|
2
|
+
$button-spacing-y: math.div($grid-unit-15, 2); // 6px
|
|
3
|
+
|
|
1
4
|
.wp-block-search__button {
|
|
2
|
-
margin-left:
|
|
5
|
+
margin-left: $button-spacing-x;
|
|
3
6
|
word-break: normal;
|
|
4
7
|
|
|
5
8
|
&.has-icon {
|
|
@@ -7,8 +10,8 @@
|
|
|
7
10
|
}
|
|
8
11
|
|
|
9
12
|
svg {
|
|
10
|
-
min-width:
|
|
11
|
-
min-height:
|
|
13
|
+
min-width: $grid-unit-30;
|
|
14
|
+
min-height: $grid-unit-30;
|
|
12
15
|
fill: currentColor;
|
|
13
16
|
vertical-align: text-bottom;
|
|
14
17
|
}
|
|
@@ -17,8 +20,8 @@
|
|
|
17
20
|
// These rules are set to zero specificity to keep the default styles for search buttons.
|
|
18
21
|
// They are needed for backwards compatibility.
|
|
19
22
|
:where(.wp-block-search__button) {
|
|
20
|
-
border: 1px solid
|
|
21
|
-
padding:
|
|
23
|
+
border: 1px solid $gray-400;
|
|
24
|
+
padding: $button-spacing-y $button-spacing-x;
|
|
22
25
|
}
|
|
23
26
|
|
|
24
27
|
.wp-block-search__inside-wrapper {
|
|
@@ -33,12 +36,12 @@
|
|
|
33
36
|
}
|
|
34
37
|
|
|
35
38
|
.wp-block-search__input {
|
|
36
|
-
padding:
|
|
39
|
+
padding: $grid-unit-10;
|
|
37
40
|
flex-grow: 1;
|
|
38
41
|
margin-left: 0;
|
|
39
42
|
margin-right: 0;
|
|
40
|
-
min-width:
|
|
41
|
-
border: 1px solid
|
|
43
|
+
min-width: 3rem;
|
|
44
|
+
border: 1px solid $gray-600;
|
|
42
45
|
// !important used to forcibly prevent undesired application of
|
|
43
46
|
// text-decoration styles on the input field.
|
|
44
47
|
text-decoration: unset !important;
|
|
@@ -52,13 +55,14 @@
|
|
|
52
55
|
|
|
53
56
|
// We are lowering the specificity so that the button element can override the rule for the button inside the search block.
|
|
54
57
|
:where(.wp-block-search__button-inside .wp-block-search__inside-wrapper) {
|
|
55
|
-
padding:
|
|
56
|
-
border: 1px solid
|
|
58
|
+
padding: $grid-unit-05;
|
|
59
|
+
border: 1px solid $gray-600;
|
|
60
|
+
box-sizing: border-box;
|
|
57
61
|
|
|
58
62
|
.wp-block-search__input {
|
|
59
63
|
border-radius: 0;
|
|
60
64
|
border: none;
|
|
61
|
-
padding: 0
|
|
65
|
+
padding: 0 $grid-unit-05;
|
|
62
66
|
|
|
63
67
|
&:focus {
|
|
64
68
|
outline: none;
|
|
@@ -67,7 +71,7 @@
|
|
|
67
71
|
|
|
68
72
|
// For lower specificity.
|
|
69
73
|
:where(.wp-block-search__button) {
|
|
70
|
-
padding:
|
|
74
|
+
padding: $grid-unit-05 $grid-unit-10;
|
|
71
75
|
}
|
|
72
76
|
}
|
|
73
77
|
|
package/src/spacer/edit.js
CHANGED
|
@@ -78,8 +78,16 @@ const SpacerEdit = ( {
|
|
|
78
78
|
setAttributes,
|
|
79
79
|
toggleSelection,
|
|
80
80
|
context,
|
|
81
|
+
__unstableParentLayout: parentLayout,
|
|
81
82
|
} ) => {
|
|
82
83
|
const { orientation } = context;
|
|
84
|
+
const { orientation: parentOrientation, type } = parentLayout || {};
|
|
85
|
+
// If the spacer is inside a flex container, it should either inherit the orientation
|
|
86
|
+
// of the parent or use the flex default orientation.
|
|
87
|
+
const inheritedOrientation =
|
|
88
|
+
! parentOrientation && type === 'flex'
|
|
89
|
+
? 'horizontal'
|
|
90
|
+
: parentOrientation || orientation;
|
|
83
91
|
const { height, width } = attributes;
|
|
84
92
|
|
|
85
93
|
const [ isResizing, setIsResizing ] = useState( false );
|
|
@@ -104,13 +112,18 @@ const SpacerEdit = ( {
|
|
|
104
112
|
|
|
105
113
|
const style = {
|
|
106
114
|
height:
|
|
107
|
-
|
|
115
|
+
inheritedOrientation === 'horizontal'
|
|
108
116
|
? 24
|
|
109
117
|
: temporaryHeight || height || undefined,
|
|
110
118
|
width:
|
|
111
|
-
|
|
119
|
+
inheritedOrientation === 'horizontal'
|
|
112
120
|
? temporaryWidth || width || undefined
|
|
113
121
|
: undefined,
|
|
122
|
+
// In vertical flex containers, the spacer shrinks to nothing without a minimum width.
|
|
123
|
+
minWidth:
|
|
124
|
+
inheritedOrientation === 'vertical' && type === 'flex'
|
|
125
|
+
? 48
|
|
126
|
+
: undefined,
|
|
114
127
|
};
|
|
115
128
|
|
|
116
129
|
const resizableBoxWithOrientation = ( blockOrientation ) => {
|
|
@@ -166,7 +179,7 @@ const SpacerEdit = ( {
|
|
|
166
179
|
};
|
|
167
180
|
|
|
168
181
|
useEffect( () => {
|
|
169
|
-
if (
|
|
182
|
+
if ( inheritedOrientation === 'horizontal' && ! width ) {
|
|
170
183
|
setAttributes( {
|
|
171
184
|
height: '0px',
|
|
172
185
|
width: '72px',
|
|
@@ -177,13 +190,13 @@ const SpacerEdit = ( {
|
|
|
177
190
|
return (
|
|
178
191
|
<>
|
|
179
192
|
<View { ...useBlockProps( { style } ) }>
|
|
180
|
-
{ resizableBoxWithOrientation(
|
|
193
|
+
{ resizableBoxWithOrientation( inheritedOrientation ) }
|
|
181
194
|
</View>
|
|
182
195
|
<SpacerControls
|
|
183
196
|
setAttributes={ setAttributes }
|
|
184
197
|
height={ temporaryHeight || height }
|
|
185
198
|
width={ temporaryWidth || width }
|
|
186
|
-
orientation={
|
|
199
|
+
orientation={ inheritedOrientation }
|
|
187
200
|
isResizing={ isResizing }
|
|
188
201
|
/>
|
|
189
202
|
</>
|
package/src/style.scss
CHANGED
|
@@ -32,6 +32,7 @@
|
|
|
32
32
|
@import "./post-featured-image/style.scss";
|
|
33
33
|
@import "./post-navigation-link/style.scss";
|
|
34
34
|
@import "./post-terms/style.scss";
|
|
35
|
+
@import "./post-time-to-read/style.scss";
|
|
35
36
|
@import "./post-title/style.scss";
|
|
36
37
|
@import "./preformatted/style.scss";
|
|
37
38
|
@import "./pullquote/style.scss";
|
|
@@ -34,7 +34,7 @@ exports[`Video block transforms to Group block 1`] = `
|
|
|
34
34
|
|
|
35
35
|
exports[`Video block transforms to Media & Text block 1`] = `
|
|
36
36
|
"<!-- wp:media-text {"mediaType":"video"} -->
|
|
37
|
-
<div class="wp-block-media-text
|
|
37
|
+
<div class="wp-block-media-text is-stacked-on-mobile"><figure class="wp-block-media-text__media"><video controls src="https://i.cloudup.com/YtZFJbuQCE.mov"></video></figure><div class="wp-block-media-text__content"><!-- wp:paragraph -->
|
|
38
38
|
<p></p>
|
|
39
39
|
<!-- /wp:paragraph --></div></div>
|
|
40
40
|
<!-- /wp:media-text -->"
|