@wordpress/block-library 7.6.0 → 7.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/button/deprecated.js +175 -35
- package/build/button/deprecated.js.map +1 -1
- package/build/button/edit.js +1 -1
- package/build/button/edit.js.map +1 -1
- package/build/button/save.js +1 -1
- package/build/button/save.js.map +1 -1
- package/build/columns/index.js +3 -1
- package/build/columns/index.js.map +1 -1
- package/build/cover/deprecated.js +212 -207
- package/build/cover/deprecated.js.map +1 -1
- package/build/cover/edit/index.js +13 -3
- package/build/cover/edit/index.js.map +1 -1
- package/build/cover/save.js +18 -5
- package/build/cover/save.js.map +1 -1
- package/build/cover/shared.js +14 -17
- package/build/cover/shared.js.map +1 -1
- package/build/file/edit.js +1 -1
- package/build/file/edit.js.map +1 -1
- package/build/file/save.js +9 -1
- package/build/file/save.js.map +1 -1
- package/build/gallery/gap-styles.js +14 -4
- package/build/gallery/gap-styles.js.map +1 -1
- package/build/gallery/index.js +1 -1
- package/build/image/edit.js +5 -59
- package/build/image/edit.js.map +1 -1
- package/build/image/edit.native.js +56 -3
- package/build/image/edit.native.js.map +1 -1
- package/build/image/image.js +3 -13
- package/build/image/image.js.map +1 -1
- package/build/list-item/hooks/use-split.js +17 -3
- package/build/list-item/hooks/use-split.js.map +1 -1
- package/build/navigation-link/edit.js +31 -5
- package/build/navigation-link/edit.js.map +1 -1
- package/build/post-author-name/index.js +3 -0
- package/build/post-author-name/index.js.map +1 -1
- package/build/post-author-name/transforms.js +41 -0
- package/build/post-author-name/transforms.js.map +1 -0
- package/build/post-comments-form/form.js +11 -1
- package/build/post-comments-form/form.js.map +1 -1
- package/build/post-date/edit.js +13 -7
- package/build/post-date/edit.js.map +1 -1
- package/build/search/edit.js +1 -1
- package/build/search/edit.js.map +1 -1
- package/build/search/index.js +4 -0
- package/build/search/index.js.map +1 -1
- package/build/shortcode/edit.native.js +16 -13
- package/build/shortcode/edit.native.js.map +1 -1
- package/build/social-links/edit.js +2 -2
- package/build/social-links/edit.js.map +1 -1
- package/build/table-of-contents/edit.js +11 -3
- package/build/table-of-contents/edit.js.map +1 -1
- package/build-module/button/deprecated.js +175 -35
- package/build-module/button/deprecated.js.map +1 -1
- package/build-module/button/edit.js +2 -2
- package/build-module/button/edit.js.map +1 -1
- package/build-module/button/save.js +2 -2
- package/build-module/button/save.js.map +1 -1
- package/build-module/columns/index.js +3 -1
- package/build-module/columns/index.js.map +1 -1
- package/build-module/cover/deprecated.js +206 -198
- package/build-module/cover/deprecated.js.map +1 -1
- package/build-module/cover/edit/index.js +14 -4
- package/build-module/cover/edit/index.js.map +1 -1
- package/build-module/cover/save.js +19 -6
- package/build-module/cover/save.js.map +1 -1
- package/build-module/cover/shared.js +11 -12
- package/build-module/cover/shared.js.map +1 -1
- package/build-module/file/edit.js +2 -2
- package/build-module/file/edit.js.map +1 -1
- package/build-module/file/save.js +7 -2
- package/build-module/file/save.js.map +1 -1
- package/build-module/gallery/gap-styles.js +14 -4
- package/build-module/gallery/gap-styles.js.map +1 -1
- package/build-module/gallery/index.js +1 -1
- package/build-module/image/edit.js +5 -56
- package/build-module/image/edit.js.map +1 -1
- package/build-module/image/edit.native.js +57 -5
- package/build-module/image/edit.native.js.map +1 -1
- package/build-module/image/image.js +4 -14
- package/build-module/image/image.js.map +1 -1
- package/build-module/list-item/hooks/use-split.js +19 -5
- package/build-module/list-item/hooks/use-split.js.map +1 -1
- package/build-module/navigation-link/edit.js +31 -6
- package/build-module/navigation-link/edit.js.map +1 -1
- package/build-module/post-author-name/index.js +2 -0
- package/build-module/post-author-name/index.js.map +1 -1
- package/build-module/post-author-name/transforms.js +32 -0
- package/build-module/post-author-name/transforms.js.map +1 -0
- package/build-module/post-comments-form/form.js +7 -1
- package/build-module/post-comments-form/form.js.map +1 -1
- package/build-module/post-date/edit.js +15 -9
- package/build-module/post-date/edit.js.map +1 -1
- package/build-module/search/edit.js +2 -2
- package/build-module/search/edit.js.map +1 -1
- package/build-module/search/index.js +4 -0
- package/build-module/search/index.js.map +1 -1
- package/build-module/shortcode/edit.native.js +17 -13
- package/build-module/shortcode/edit.native.js.map +1 -1
- package/build-module/social-links/edit.js +2 -2
- package/build-module/social-links/edit.js.map +1 -1
- package/build-module/table-of-contents/edit.js +12 -4
- package/build-module/table-of-contents/edit.js.map +1 -1
- package/build-style/cover/style-rtl.css +32 -23
- package/build-style/cover/style.css +32 -23
- package/build-style/site-logo/style-rtl.css +4 -0
- package/build-style/site-logo/style.css +4 -0
- package/build-style/style-rtl.css +36 -23
- package/build-style/style.css +36 -23
- package/package.json +28 -28
- package/src/button/deprecated.js +145 -0
- package/src/button/edit.js +3 -1
- package/src/button/save.js +3 -1
- package/src/buttons/test/__snapshots__/edit.native.js.snap +1 -1
- package/src/buttons/test/edit.native.js +1 -1
- package/src/columns/block.json +3 -1
- package/src/cover/deprecated.js +230 -183
- package/src/cover/edit/index.js +25 -13
- package/src/cover/save.js +26 -13
- package/src/cover/shared.js +5 -7
- package/src/cover/style.scss +27 -22
- package/src/file/edit.js +5 -1
- package/src/file/save.js +14 -2
- package/src/gallery/block.json +1 -1
- package/src/gallery/gap-styles.js +21 -6
- package/src/gallery/index.php +23 -12
- package/src/image/edit.js +1 -53
- package/src/image/edit.native.js +65 -3
- package/src/image/image.js +2 -11
- package/src/image/styles.native.scss +11 -0
- package/src/list-item/hooks/use-split.js +18 -9
- package/src/navigation-link/edit.js +35 -5
- package/src/navigation-link/test/edit.js +0 -20
- package/src/post-author/index.php +3 -2
- package/src/post-author-name/index.js +2 -0
- package/src/post-author-name/index.php +1 -1
- package/src/post-author-name/transforms.js +25 -0
- package/src/post-comments/index.php +1 -1
- package/src/post-comments-form/form.js +11 -1
- package/src/post-comments-form/index.php +1 -1
- package/src/post-date/edit.js +4 -3
- package/src/query-pagination/index.php +0 -1
- package/src/search/block.json +4 -0
- package/src/search/edit.js +3 -1
- package/src/search/index.php +28 -15
- package/src/shortcode/edit.native.js +29 -15
- package/src/shortcode/style.native.scss +11 -4
- package/src/shortcode/test/__snapshots__/edit.native.js.snap +9 -0
- package/src/shortcode/test/edit.native.js +58 -40
- package/src/site-logo/style.scss +6 -0
- package/src/social-links/edit.js +11 -10
- package/src/table-of-contents/edit.js +19 -6
|
@@ -1,7 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
import classnames from 'classnames';
|
|
5
|
+
|
|
1
6
|
/**
|
|
2
7
|
* WordPress dependencies
|
|
3
8
|
*/
|
|
4
9
|
import { __ } from '@wordpress/i18n';
|
|
10
|
+
import { __experimentalElementButtonClassName } from '@wordpress/block-editor';
|
|
5
11
|
import { useDisabled, useInstanceId } from '@wordpress/compose';
|
|
6
12
|
|
|
7
13
|
const CommentsForm = () => {
|
|
@@ -27,7 +33,11 @@ const CommentsForm = () => {
|
|
|
27
33
|
<input
|
|
28
34
|
name="submit"
|
|
29
35
|
type="submit"
|
|
30
|
-
className=
|
|
36
|
+
className={ classnames(
|
|
37
|
+
'submit',
|
|
38
|
+
'wp-block-button__link',
|
|
39
|
+
__experimentalElementButtonClassName
|
|
40
|
+
) }
|
|
31
41
|
label={ __( 'Post Comment' ) }
|
|
32
42
|
value={ __( 'Post Comment' ) }
|
|
33
43
|
/>
|
|
@@ -72,7 +72,7 @@ add_action( 'init', 'register_block_core_post_comments_form' );
|
|
|
72
72
|
*/
|
|
73
73
|
function post_comments_form_block_form_defaults( $fields ) {
|
|
74
74
|
if ( wp_is_block_theme() ) {
|
|
75
|
-
$fields['submit_button'] = '<input name="%1$s" type="submit" id="%2$s" class="%3$s wp-block-button__link" value="%4$s" />';
|
|
75
|
+
$fields['submit_button'] = '<input name="%1$s" type="submit" id="%2$s" class="%3$s wp-block-button__link ' . WP_Theme_JSON_Gutenberg::__EXPERIMENTAL_ELEMENT_BUTTON_CLASS_NAME . '" value="%4$s" />';
|
|
76
76
|
$fields['submit_field'] = '<p class="form-submit wp-block-button">%1$s %2$s</p>';
|
|
77
77
|
}
|
|
78
78
|
|
package/src/post-date/edit.js
CHANGED
|
@@ -18,13 +18,13 @@ import {
|
|
|
18
18
|
InspectorControls,
|
|
19
19
|
useBlockProps,
|
|
20
20
|
__experimentalDateFormatPicker as DateFormatPicker,
|
|
21
|
+
__experimentalPublishDateTimePicker as PublishDateTimePicker,
|
|
21
22
|
} from '@wordpress/block-editor';
|
|
22
23
|
import {
|
|
23
24
|
Dropdown,
|
|
24
25
|
ToolbarGroup,
|
|
25
26
|
ToolbarButton,
|
|
26
27
|
ToggleControl,
|
|
27
|
-
DateTimePicker,
|
|
28
28
|
PanelBody,
|
|
29
29
|
} from '@wordpress/components';
|
|
30
30
|
import { __, sprintf } from '@wordpress/i18n';
|
|
@@ -101,13 +101,14 @@ export default function PostDateEdit( {
|
|
|
101
101
|
<ToolbarGroup>
|
|
102
102
|
<Dropdown
|
|
103
103
|
popoverProps={ { anchorRef: timeRef.current } }
|
|
104
|
-
renderContent={ () => (
|
|
105
|
-
<
|
|
104
|
+
renderContent={ ( { onClose } ) => (
|
|
105
|
+
<PublishDateTimePicker
|
|
106
106
|
currentDate={ date }
|
|
107
107
|
onChange={ setDate }
|
|
108
108
|
is12Hour={ is12HourFormat(
|
|
109
109
|
siteTimeFormat
|
|
110
110
|
) }
|
|
111
|
+
onClose={ onClose }
|
|
111
112
|
/>
|
|
112
113
|
) }
|
|
113
114
|
renderToggle={ ( { isOpen, onToggle } ) => {
|
package/src/search/block.json
CHANGED
package/src/search/edit.js
CHANGED
|
@@ -14,6 +14,7 @@ import {
|
|
|
14
14
|
__experimentalUseBorderProps as useBorderProps,
|
|
15
15
|
__experimentalUseColorProps as useColorProps,
|
|
16
16
|
store as blockEditorStore,
|
|
17
|
+
__experimentalElementButtonClassName,
|
|
17
18
|
} from '@wordpress/block-editor';
|
|
18
19
|
import { useDispatch, useSelect } from '@wordpress/data';
|
|
19
20
|
import { useEffect } from '@wordpress/element';
|
|
@@ -241,7 +242,8 @@ export default function SearchEdit( {
|
|
|
241
242
|
'wp-block-search__button',
|
|
242
243
|
colorProps.className,
|
|
243
244
|
isButtonPositionInside ? undefined : borderProps.className,
|
|
244
|
-
buttonUseIcon ? 'has-icon' : undefined
|
|
245
|
+
buttonUseIcon ? 'has-icon' : undefined,
|
|
246
|
+
__experimentalElementButtonClassName
|
|
245
247
|
);
|
|
246
248
|
const buttonStyles = {
|
|
247
249
|
...colorProps.style,
|
package/src/search/index.php
CHANGED
|
@@ -13,8 +13,6 @@
|
|
|
13
13
|
* @return string The search block markup.
|
|
14
14
|
*/
|
|
15
15
|
function render_block_core_search( $attributes ) {
|
|
16
|
-
static $instance_id = 0;
|
|
17
|
-
|
|
18
16
|
// Older versions of the Search block defaulted the label and buttonText
|
|
19
17
|
// attributes to `__( 'Search' )` meaning that many posts contain `<!--
|
|
20
18
|
// wp:search /-->`. Support these by defaulting an undefined label and
|
|
@@ -27,17 +25,19 @@ function render_block_core_search( $attributes ) {
|
|
|
27
25
|
)
|
|
28
26
|
);
|
|
29
27
|
|
|
30
|
-
$input_id
|
|
31
|
-
$classnames
|
|
32
|
-
$show_label
|
|
33
|
-
$use_icon_button
|
|
34
|
-
$show_input
|
|
35
|
-
$show_button
|
|
36
|
-
$
|
|
37
|
-
$
|
|
38
|
-
$
|
|
39
|
-
$
|
|
40
|
-
$
|
|
28
|
+
$input_id = wp_unique_id( 'wp-block-search__input-' );
|
|
29
|
+
$classnames = classnames_for_block_core_search( $attributes );
|
|
30
|
+
$show_label = ( ! empty( $attributes['showLabel'] ) ) ? true : false;
|
|
31
|
+
$use_icon_button = ( ! empty( $attributes['buttonUseIcon'] ) ) ? true : false;
|
|
32
|
+
$show_input = ( ! empty( $attributes['buttonPosition'] ) && 'button-only' === $attributes['buttonPosition'] ) ? false : true;
|
|
33
|
+
$show_button = ( ! empty( $attributes['buttonPosition'] ) && 'no-button' === $attributes['buttonPosition'] ) ? false : true;
|
|
34
|
+
$query_params = ( ! empty( $attributes['query'] ) ) ? $attributes['query'] : array();
|
|
35
|
+
$input_markup = '';
|
|
36
|
+
$button_markup = '';
|
|
37
|
+
$query_params_markup = '';
|
|
38
|
+
$inline_styles = styles_for_block_core_search( $attributes );
|
|
39
|
+
$color_classes = get_color_classes_for_block_core_search( $attributes );
|
|
40
|
+
$is_button_inside = ! empty( $attributes['buttonPosition'] ) &&
|
|
41
41
|
'button-inside' === $attributes['buttonPosition'];
|
|
42
42
|
// Border color classes need to be applied to the elements that have a border color.
|
|
43
43
|
$border_color_classes = get_border_color_classes_for_block_core_search( $attributes );
|
|
@@ -63,12 +63,22 @@ function render_block_core_search( $attributes ) {
|
|
|
63
63
|
'<input type="search" id="%s" class="wp-block-search__input %s" name="s" value="%s" placeholder="%s" %s required />',
|
|
64
64
|
$input_id,
|
|
65
65
|
esc_attr( $input_classes ),
|
|
66
|
-
|
|
66
|
+
get_search_query(),
|
|
67
67
|
esc_attr( $attributes['placeholder'] ),
|
|
68
68
|
$inline_styles['input']
|
|
69
69
|
);
|
|
70
70
|
}
|
|
71
71
|
|
|
72
|
+
if ( count( $query_params ) > 0 ) {
|
|
73
|
+
foreach ( $query_params as $param => $value ) {
|
|
74
|
+
$query_params_markup .= sprintf(
|
|
75
|
+
'<input type="hidden" name="%s" value="%s" />',
|
|
76
|
+
esc_attr( $param ),
|
|
77
|
+
esc_attr( $value )
|
|
78
|
+
);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
72
82
|
if ( $show_button ) {
|
|
73
83
|
$button_internal_markup = '';
|
|
74
84
|
$button_classes = $color_classes;
|
|
@@ -91,6 +101,9 @@ function render_block_core_search( $attributes ) {
|
|
|
91
101
|
</svg>';
|
|
92
102
|
}
|
|
93
103
|
|
|
104
|
+
// Include the button element class.
|
|
105
|
+
$button_classes .= ' ' . WP_Theme_JSON_GUTENBERG::__EXPERIMENTAL_ELEMENT_BUTTON_CLASS_NAME;
|
|
106
|
+
|
|
94
107
|
$button_markup = sprintf(
|
|
95
108
|
'<button type="submit" class="wp-block-search__button %s" %s %s>%s</button>',
|
|
96
109
|
esc_attr( $button_classes ),
|
|
@@ -105,7 +118,7 @@ function render_block_core_search( $attributes ) {
|
|
|
105
118
|
'<div class="wp-block-search__inside-wrapper %s" %s>%s</div>',
|
|
106
119
|
esc_attr( $field_markup_classes ),
|
|
107
120
|
$inline_styles['wrapper'],
|
|
108
|
-
$input_markup . $button_markup
|
|
121
|
+
$input_markup . $query_params_markup . $button_markup
|
|
109
122
|
);
|
|
110
123
|
$wrapper_attributes = get_block_wrapper_attributes( array( 'class' => $classnames ) );
|
|
111
124
|
|
|
@@ -9,6 +9,7 @@ import { View, Text } from 'react-native';
|
|
|
9
9
|
import { __ } from '@wordpress/i18n';
|
|
10
10
|
import { PlainText } from '@wordpress/block-editor';
|
|
11
11
|
import { withPreferredColorScheme } from '@wordpress/compose';
|
|
12
|
+
import { useCallback } from '@wordpress/element';
|
|
12
13
|
|
|
13
14
|
/**
|
|
14
15
|
* Internal dependencies
|
|
@@ -23,11 +24,16 @@ export function ShortcodeEdit( props ) {
|
|
|
23
24
|
onFocus,
|
|
24
25
|
onBlur,
|
|
25
26
|
getStylesFromColorScheme,
|
|
27
|
+
blockWidth,
|
|
26
28
|
} = props;
|
|
27
29
|
const titleStyle = getStylesFromColorScheme(
|
|
28
30
|
styles.blockTitle,
|
|
29
31
|
styles.blockTitleDark
|
|
30
32
|
);
|
|
33
|
+
const shortcodeContainerStyle = getStylesFromColorScheme(
|
|
34
|
+
styles.blockShortcodeContainer,
|
|
35
|
+
styles.blockShortcodeContainerDark
|
|
36
|
+
);
|
|
31
37
|
const shortcodeStyle = getStylesFromColorScheme(
|
|
32
38
|
styles.blockShortcode,
|
|
33
39
|
styles.blockShortcodeDark
|
|
@@ -37,24 +43,32 @@ export function ShortcodeEdit( props ) {
|
|
|
37
43
|
styles.placeholderDark
|
|
38
44
|
);
|
|
39
45
|
|
|
46
|
+
const maxWidth =
|
|
47
|
+
blockWidth -
|
|
48
|
+
shortcodeContainerStyle.paddingLeft +
|
|
49
|
+
shortcodeContainerStyle.paddingRight;
|
|
50
|
+
|
|
51
|
+
const onChange = useCallback( ( text ) => setAttributes( { text } ), [
|
|
52
|
+
setAttributes,
|
|
53
|
+
] );
|
|
54
|
+
|
|
40
55
|
return (
|
|
41
56
|
<View>
|
|
42
57
|
<Text style={ titleStyle }>{ __( 'Shortcode' ) }</Text>
|
|
43
|
-
<
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
/>
|
|
58
|
+
<View style={ shortcodeContainerStyle }>
|
|
59
|
+
<PlainText
|
|
60
|
+
__experimentalVersion={ 2 }
|
|
61
|
+
value={ attributes.text }
|
|
62
|
+
style={ shortcodeStyle }
|
|
63
|
+
onChange={ onChange }
|
|
64
|
+
placeholder={ __( 'Add a shortcode…' ) }
|
|
65
|
+
onFocus={ onFocus }
|
|
66
|
+
onBlur={ onBlur }
|
|
67
|
+
placeholderTextColor={ placeholderStyle.color }
|
|
68
|
+
maxWidth={ maxWidth }
|
|
69
|
+
disableAutocorrection
|
|
70
|
+
/>
|
|
71
|
+
</View>
|
|
58
72
|
</View>
|
|
59
73
|
);
|
|
60
74
|
}
|
|
@@ -11,18 +11,25 @@
|
|
|
11
11
|
color: $gray-50;
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
+
.blockShortcodeContainer {
|
|
15
|
+
padding: 12px;
|
|
16
|
+
border-radius: 4px;
|
|
17
|
+
background-color: $gray-light;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
.blockShortcodeContainerDark {
|
|
21
|
+
background-color: $gray-100;
|
|
22
|
+
}
|
|
23
|
+
|
|
14
24
|
.blockShortcode {
|
|
15
25
|
font-family: $default-monospace-font;
|
|
16
26
|
font-weight: 400;
|
|
17
27
|
font-size: 14px;
|
|
18
|
-
|
|
19
|
-
border-radius: 4px;
|
|
20
|
-
background-color: $gray-light;
|
|
28
|
+
color: $gray-900;
|
|
21
29
|
}
|
|
22
30
|
|
|
23
31
|
.blockShortcodeDark {
|
|
24
32
|
color: $white;
|
|
25
|
-
background-color: $gray-100;
|
|
26
33
|
}
|
|
27
34
|
|
|
28
35
|
.placeholder {
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
+
|
|
3
|
+
exports[`Shortcode block edits content 1`] = `
|
|
4
|
+
"<!-- wp:shortcode -->
|
|
5
|
+
[youtube https://www.youtube.com/watch?v=ssfHW5lwFZg]
|
|
6
|
+
<!-- /wp:shortcode -->"
|
|
7
|
+
`;
|
|
8
|
+
|
|
9
|
+
exports[`Shortcode block inserts block 1`] = `"<!-- wp:shortcode /-->"`;
|
|
@@ -1,58 +1,76 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* External dependencies
|
|
3
3
|
*/
|
|
4
|
-
import
|
|
5
|
-
|
|
4
|
+
import {
|
|
5
|
+
getEditorHtml,
|
|
6
|
+
initializeEditor,
|
|
7
|
+
fireEvent,
|
|
8
|
+
waitFor,
|
|
9
|
+
} from 'test/helpers';
|
|
6
10
|
|
|
7
11
|
/**
|
|
8
12
|
* WordPress dependencies
|
|
9
13
|
*/
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
14
|
+
import { getBlockTypes, unregisterBlockType } from '@wordpress/blocks';
|
|
15
|
+
import { registerCoreBlocks } from '@wordpress/block-library';
|
|
12
16
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
+
beforeAll( () => {
|
|
18
|
+
// Register all core blocks
|
|
19
|
+
registerCoreBlocks();
|
|
20
|
+
} );
|
|
21
|
+
|
|
22
|
+
afterAll( () => {
|
|
23
|
+
// Clean up registered blocks
|
|
24
|
+
getBlockTypes().forEach( ( block ) => {
|
|
25
|
+
unregisterBlockType( block.name );
|
|
26
|
+
} );
|
|
27
|
+
} );
|
|
28
|
+
|
|
29
|
+
describe( 'Shortcode block', () => {
|
|
30
|
+
it( 'inserts block', async () => {
|
|
31
|
+
const {
|
|
32
|
+
getByA11yLabel,
|
|
33
|
+
getByTestId,
|
|
34
|
+
getByText,
|
|
35
|
+
} = await initializeEditor();
|
|
17
36
|
|
|
18
|
-
|
|
19
|
-
<BlockEdit name={ name } clientId={ clientId || 0 } { ...props } />
|
|
20
|
-
);
|
|
37
|
+
fireEvent.press( getByA11yLabel( 'Add block' ) );
|
|
21
38
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
39
|
+
const blockList = getByTestId( 'InserterUI-Blocks' );
|
|
40
|
+
// onScroll event used to force the FlatList to render all items
|
|
41
|
+
fireEvent.scroll( blockList, {
|
|
42
|
+
nativeEvent: {
|
|
43
|
+
contentOffset: { y: 0, x: 0 },
|
|
44
|
+
contentSize: { width: 100, height: 100 },
|
|
45
|
+
layoutMeasurement: { width: 100, height: 100 },
|
|
46
|
+
},
|
|
27
47
|
} );
|
|
28
|
-
} );
|
|
29
48
|
|
|
30
|
-
|
|
31
|
-
unregisterBlockType( name );
|
|
32
|
-
} );
|
|
49
|
+
fireEvent.press( await waitFor( () => getByText( 'Shortcode' ) ) );
|
|
33
50
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
<Shortcode attributes={ { text: '' } } />
|
|
37
|
-
);
|
|
38
|
-
const rendered = component.toJSON();
|
|
39
|
-
expect( rendered ).toBeTruthy();
|
|
51
|
+
expect( getByA11yLabel( /Shortcode Block\. Row 1/ ) ).toBeVisible();
|
|
52
|
+
expect( getEditorHtml() ).toMatchSnapshot();
|
|
40
53
|
} );
|
|
41
54
|
|
|
42
|
-
it( '
|
|
43
|
-
const
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
'[youtube https://www.youtube.com/watch?v=ssfHW5lwFZg]',
|
|
48
|
-
} }
|
|
49
|
-
/>
|
|
50
|
-
);
|
|
51
|
-
const testInstance = component.root;
|
|
52
|
-
const textInput = testInstance.findByType( TextInput );
|
|
53
|
-
expect( textInput ).toBeTruthy();
|
|
54
|
-
expect( textInput.props.value ).toBe(
|
|
55
|
-
'[youtube https://www.youtube.com/watch?v=ssfHW5lwFZg]'
|
|
55
|
+
it( 'edits content', async () => {
|
|
56
|
+
const { getByA11yLabel, getByPlaceholderText } = await initializeEditor(
|
|
57
|
+
{
|
|
58
|
+
initialHtml: '<!-- wp:shortcode /-->',
|
|
59
|
+
}
|
|
56
60
|
);
|
|
61
|
+
const shortcodeBlock = getByA11yLabel( /Shortcode Block\. Row 1/ );
|
|
62
|
+
fireEvent.press( shortcodeBlock );
|
|
63
|
+
|
|
64
|
+
const textField = getByPlaceholderText( 'Add a shortcode…' );
|
|
65
|
+
fireEvent( textField, 'focus' );
|
|
66
|
+
fireEvent( textField, 'onChange', {
|
|
67
|
+
nativeEvent: {
|
|
68
|
+
eventCount: 1,
|
|
69
|
+
target: undefined,
|
|
70
|
+
text: '[youtube https://www.youtube.com/watch?v=ssfHW5lwFZg]',
|
|
71
|
+
},
|
|
72
|
+
} );
|
|
73
|
+
|
|
74
|
+
expect( getEditorHtml() ).toMatchSnapshot();
|
|
57
75
|
} );
|
|
58
76
|
} );
|
package/src/site-logo/style.scss
CHANGED
package/src/social-links/edit.js
CHANGED
|
@@ -215,16 +215,17 @@ export function SocialLinksEdit( props ) {
|
|
|
215
215
|
__experimentalIsRenderedInSidebar
|
|
216
216
|
title={ __( 'Color' ) }
|
|
217
217
|
colorSettings={ colorSettings }
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
218
|
+
>
|
|
219
|
+
{ ! logosOnly && (
|
|
220
|
+
<ContrastChecker
|
|
221
|
+
{ ...{
|
|
222
|
+
textColor: iconColorValue,
|
|
223
|
+
backgroundColor: iconBackgroundColorValue,
|
|
224
|
+
} }
|
|
225
|
+
isLargeText={ false }
|
|
226
|
+
/>
|
|
227
|
+
) }
|
|
228
|
+
</PanelColorSettings>
|
|
228
229
|
</InspectorControls>
|
|
229
230
|
<ul { ...innerBlocksProps } />
|
|
230
231
|
</Fragment>
|
|
@@ -13,7 +13,7 @@ import {
|
|
|
13
13
|
store as blockEditorStore,
|
|
14
14
|
useBlockProps,
|
|
15
15
|
} from '@wordpress/block-editor';
|
|
16
|
-
import { createBlock
|
|
16
|
+
import { createBlock } from '@wordpress/blocks';
|
|
17
17
|
import {
|
|
18
18
|
PanelBody,
|
|
19
19
|
Placeholder,
|
|
@@ -57,9 +57,16 @@ export default function TableOfContentsEdit( {
|
|
|
57
57
|
const blockProps = useBlockProps();
|
|
58
58
|
const disabledRef = useDisabled();
|
|
59
59
|
|
|
60
|
-
const
|
|
61
|
-
( select ) =>
|
|
62
|
-
|
|
60
|
+
const canInsertList = useSelect(
|
|
61
|
+
( select ) => {
|
|
62
|
+
const { getBlockRootClientId, canInsertBlockType } = select(
|
|
63
|
+
blockEditorStore
|
|
64
|
+
);
|
|
65
|
+
const rootClientId = getBlockRootClientId( clientId );
|
|
66
|
+
|
|
67
|
+
return canInsertBlockType( 'core/list', rootClientId );
|
|
68
|
+
},
|
|
69
|
+
[ clientId ]
|
|
63
70
|
);
|
|
64
71
|
|
|
65
72
|
const {
|
|
@@ -187,7 +194,13 @@ export default function TableOfContentsEdit( {
|
|
|
187
194
|
headingAttributes.anchor !== '';
|
|
188
195
|
|
|
189
196
|
_latestHeadings.push( {
|
|
190
|
-
|
|
197
|
+
// Convert line breaks to spaces, and get rid of HTML tags in the headings.
|
|
198
|
+
content: stripHTML(
|
|
199
|
+
headingAttributes.content.replace(
|
|
200
|
+
/(<br *\/?>)+/g,
|
|
201
|
+
' '
|
|
202
|
+
)
|
|
203
|
+
),
|
|
191
204
|
level: headingAttributes.level,
|
|
192
205
|
link: canBeLinked
|
|
193
206
|
? `${ headingPageLink }#${ headingAttributes.anchor }`
|
|
@@ -216,7 +229,7 @@ export default function TableOfContentsEdit( {
|
|
|
216
229
|
|
|
217
230
|
const headingTree = linearToNestedHeadingList( headings );
|
|
218
231
|
|
|
219
|
-
const toolbarControls =
|
|
232
|
+
const toolbarControls = canInsertList && (
|
|
220
233
|
<BlockControls>
|
|
221
234
|
<ToolbarGroup>
|
|
222
235
|
<ToolbarButton
|