@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.
Files changed (152) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/build/button/deprecated.js +175 -35
  3. package/build/button/deprecated.js.map +1 -1
  4. package/build/button/edit.js +1 -1
  5. package/build/button/edit.js.map +1 -1
  6. package/build/button/save.js +1 -1
  7. package/build/button/save.js.map +1 -1
  8. package/build/columns/index.js +3 -1
  9. package/build/columns/index.js.map +1 -1
  10. package/build/cover/deprecated.js +212 -207
  11. package/build/cover/deprecated.js.map +1 -1
  12. package/build/cover/edit/index.js +13 -3
  13. package/build/cover/edit/index.js.map +1 -1
  14. package/build/cover/save.js +18 -5
  15. package/build/cover/save.js.map +1 -1
  16. package/build/cover/shared.js +14 -17
  17. package/build/cover/shared.js.map +1 -1
  18. package/build/file/edit.js +1 -1
  19. package/build/file/edit.js.map +1 -1
  20. package/build/file/save.js +9 -1
  21. package/build/file/save.js.map +1 -1
  22. package/build/gallery/gap-styles.js +14 -4
  23. package/build/gallery/gap-styles.js.map +1 -1
  24. package/build/gallery/index.js +1 -1
  25. package/build/image/edit.js +5 -59
  26. package/build/image/edit.js.map +1 -1
  27. package/build/image/edit.native.js +56 -3
  28. package/build/image/edit.native.js.map +1 -1
  29. package/build/image/image.js +3 -13
  30. package/build/image/image.js.map +1 -1
  31. package/build/list-item/hooks/use-split.js +17 -3
  32. package/build/list-item/hooks/use-split.js.map +1 -1
  33. package/build/navigation-link/edit.js +31 -5
  34. package/build/navigation-link/edit.js.map +1 -1
  35. package/build/post-author-name/index.js +3 -0
  36. package/build/post-author-name/index.js.map +1 -1
  37. package/build/post-author-name/transforms.js +41 -0
  38. package/build/post-author-name/transforms.js.map +1 -0
  39. package/build/post-comments-form/form.js +11 -1
  40. package/build/post-comments-form/form.js.map +1 -1
  41. package/build/post-date/edit.js +13 -7
  42. package/build/post-date/edit.js.map +1 -1
  43. package/build/search/edit.js +1 -1
  44. package/build/search/edit.js.map +1 -1
  45. package/build/search/index.js +4 -0
  46. package/build/search/index.js.map +1 -1
  47. package/build/shortcode/edit.native.js +16 -13
  48. package/build/shortcode/edit.native.js.map +1 -1
  49. package/build/social-links/edit.js +2 -2
  50. package/build/social-links/edit.js.map +1 -1
  51. package/build/table-of-contents/edit.js +11 -3
  52. package/build/table-of-contents/edit.js.map +1 -1
  53. package/build-module/button/deprecated.js +175 -35
  54. package/build-module/button/deprecated.js.map +1 -1
  55. package/build-module/button/edit.js +2 -2
  56. package/build-module/button/edit.js.map +1 -1
  57. package/build-module/button/save.js +2 -2
  58. package/build-module/button/save.js.map +1 -1
  59. package/build-module/columns/index.js +3 -1
  60. package/build-module/columns/index.js.map +1 -1
  61. package/build-module/cover/deprecated.js +206 -198
  62. package/build-module/cover/deprecated.js.map +1 -1
  63. package/build-module/cover/edit/index.js +14 -4
  64. package/build-module/cover/edit/index.js.map +1 -1
  65. package/build-module/cover/save.js +19 -6
  66. package/build-module/cover/save.js.map +1 -1
  67. package/build-module/cover/shared.js +11 -12
  68. package/build-module/cover/shared.js.map +1 -1
  69. package/build-module/file/edit.js +2 -2
  70. package/build-module/file/edit.js.map +1 -1
  71. package/build-module/file/save.js +7 -2
  72. package/build-module/file/save.js.map +1 -1
  73. package/build-module/gallery/gap-styles.js +14 -4
  74. package/build-module/gallery/gap-styles.js.map +1 -1
  75. package/build-module/gallery/index.js +1 -1
  76. package/build-module/image/edit.js +5 -56
  77. package/build-module/image/edit.js.map +1 -1
  78. package/build-module/image/edit.native.js +57 -5
  79. package/build-module/image/edit.native.js.map +1 -1
  80. package/build-module/image/image.js +4 -14
  81. package/build-module/image/image.js.map +1 -1
  82. package/build-module/list-item/hooks/use-split.js +19 -5
  83. package/build-module/list-item/hooks/use-split.js.map +1 -1
  84. package/build-module/navigation-link/edit.js +31 -6
  85. package/build-module/navigation-link/edit.js.map +1 -1
  86. package/build-module/post-author-name/index.js +2 -0
  87. package/build-module/post-author-name/index.js.map +1 -1
  88. package/build-module/post-author-name/transforms.js +32 -0
  89. package/build-module/post-author-name/transforms.js.map +1 -0
  90. package/build-module/post-comments-form/form.js +7 -1
  91. package/build-module/post-comments-form/form.js.map +1 -1
  92. package/build-module/post-date/edit.js +15 -9
  93. package/build-module/post-date/edit.js.map +1 -1
  94. package/build-module/search/edit.js +2 -2
  95. package/build-module/search/edit.js.map +1 -1
  96. package/build-module/search/index.js +4 -0
  97. package/build-module/search/index.js.map +1 -1
  98. package/build-module/shortcode/edit.native.js +17 -13
  99. package/build-module/shortcode/edit.native.js.map +1 -1
  100. package/build-module/social-links/edit.js +2 -2
  101. package/build-module/social-links/edit.js.map +1 -1
  102. package/build-module/table-of-contents/edit.js +12 -4
  103. package/build-module/table-of-contents/edit.js.map +1 -1
  104. package/build-style/cover/style-rtl.css +32 -23
  105. package/build-style/cover/style.css +32 -23
  106. package/build-style/site-logo/style-rtl.css +4 -0
  107. package/build-style/site-logo/style.css +4 -0
  108. package/build-style/style-rtl.css +36 -23
  109. package/build-style/style.css +36 -23
  110. package/package.json +28 -28
  111. package/src/button/deprecated.js +145 -0
  112. package/src/button/edit.js +3 -1
  113. package/src/button/save.js +3 -1
  114. package/src/buttons/test/__snapshots__/edit.native.js.snap +1 -1
  115. package/src/buttons/test/edit.native.js +1 -1
  116. package/src/columns/block.json +3 -1
  117. package/src/cover/deprecated.js +230 -183
  118. package/src/cover/edit/index.js +25 -13
  119. package/src/cover/save.js +26 -13
  120. package/src/cover/shared.js +5 -7
  121. package/src/cover/style.scss +27 -22
  122. package/src/file/edit.js +5 -1
  123. package/src/file/save.js +14 -2
  124. package/src/gallery/block.json +1 -1
  125. package/src/gallery/gap-styles.js +21 -6
  126. package/src/gallery/index.php +23 -12
  127. package/src/image/edit.js +1 -53
  128. package/src/image/edit.native.js +65 -3
  129. package/src/image/image.js +2 -11
  130. package/src/image/styles.native.scss +11 -0
  131. package/src/list-item/hooks/use-split.js +18 -9
  132. package/src/navigation-link/edit.js +35 -5
  133. package/src/navigation-link/test/edit.js +0 -20
  134. package/src/post-author/index.php +3 -2
  135. package/src/post-author-name/index.js +2 -0
  136. package/src/post-author-name/index.php +1 -1
  137. package/src/post-author-name/transforms.js +25 -0
  138. package/src/post-comments/index.php +1 -1
  139. package/src/post-comments-form/form.js +11 -1
  140. package/src/post-comments-form/index.php +1 -1
  141. package/src/post-date/edit.js +4 -3
  142. package/src/query-pagination/index.php +0 -1
  143. package/src/search/block.json +4 -0
  144. package/src/search/edit.js +3 -1
  145. package/src/search/index.php +28 -15
  146. package/src/shortcode/edit.native.js +29 -15
  147. package/src/shortcode/style.native.scss +11 -4
  148. package/src/shortcode/test/__snapshots__/edit.native.js.snap +9 -0
  149. package/src/shortcode/test/edit.native.js +58 -40
  150. package/src/site-logo/style.scss +6 -0
  151. package/src/social-links/edit.js +11 -10
  152. 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="submit wp-block-button__link"
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
 
@@ -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
- <DateTimePicker
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 } ) => {
@@ -20,7 +20,6 @@ function render_block_core_query_pagination( $attributes, $content ) {
20
20
 
21
21
  $wrapper_attributes = get_block_wrapper_attributes(
22
22
  array(
23
- 'role' => 'navigation',
24
23
  'aria-label' => __( 'Pagination' ),
25
24
  )
26
25
  );
@@ -38,6 +38,10 @@
38
38
  "buttonUseIcon": {
39
39
  "type": "boolean",
40
40
  "default": false
41
+ },
42
+ "query": {
43
+ "type": "object",
44
+ "default": {}
41
45
  }
42
46
  },
43
47
  "supports": {
@@ -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,
@@ -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 = 'wp-block-search__input-' . ++$instance_id;
31
- $classnames = classnames_for_block_core_search( $attributes );
32
- $show_label = ( ! empty( $attributes['showLabel'] ) ) ? true : false;
33
- $use_icon_button = ( ! empty( $attributes['buttonUseIcon'] ) ) ? true : false;
34
- $show_input = ( ! empty( $attributes['buttonPosition'] ) && 'button-only' === $attributes['buttonPosition'] ) ? false : true;
35
- $show_button = ( ! empty( $attributes['buttonPosition'] ) && 'no-button' === $attributes['buttonPosition'] ) ? false : true;
36
- $input_markup = '';
37
- $button_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'] ) &&
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
- esc_attr( get_search_query() ),
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
- <PlainText
44
- value={ attributes.text }
45
- style={ shortcodeStyle }
46
- multiline={ true }
47
- underlineColorAndroid="transparent"
48
- onChange={ ( text ) => setAttributes( { text } ) }
49
- placeholder={ __( 'Add a shortcode…' ) }
50
- aria-label={ __( 'Shortcode' ) }
51
- isSelected={ props.isSelected }
52
- onFocus={ onFocus }
53
- onBlur={ onBlur }
54
- autoCorrect={ false }
55
- autoComplete="off"
56
- placeholderTextColor={ placeholderStyle.color }
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
- padding: 12px;
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 renderer from 'react-test-renderer';
5
- import { TextInput } from 'react-native';
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 { BlockEdit } from '@wordpress/block-editor';
11
- import { registerBlockType, unregisterBlockType } from '@wordpress/blocks';
14
+ import { getBlockTypes, unregisterBlockType } from '@wordpress/blocks';
15
+ import { registerCoreBlocks } from '@wordpress/block-library';
12
16
 
13
- /**
14
- * Internal dependencies
15
- */
16
- import { metadata, settings, name } from '../index';
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
- const Shortcode = ( { clientId, ...props } ) => (
19
- <BlockEdit name={ name } clientId={ clientId || 0 } { ...props } />
20
- );
37
+ fireEvent.press( getByA11yLabel( 'Add block' ) );
21
38
 
22
- describe( 'Shortcode', () => {
23
- beforeAll( () => {
24
- registerBlockType( name, {
25
- ...metadata,
26
- ...settings,
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
- afterAll( () => {
31
- unregisterBlockType( name );
32
- } );
49
+ fireEvent.press( await waitFor( () => getByText( 'Shortcode' ) ) );
33
50
 
34
- it( 'renders without crashing', () => {
35
- const component = renderer.create(
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( 'renders given text without crashing', () => {
43
- const component = renderer.create(
44
- <Shortcode
45
- attributes={ {
46
- text:
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
  } );
@@ -11,6 +11,12 @@
11
11
  height: auto;
12
12
  }
13
13
 
14
+ // Constrain the image to its container.
15
+ img {
16
+ height: auto;
17
+ max-width: 100%;
18
+ }
19
+
14
20
  // Inherit border radius from style variations.
15
21
  a,
16
22
  img {
@@ -215,16 +215,17 @@ export function SocialLinksEdit( props ) {
215
215
  __experimentalIsRenderedInSidebar
216
216
  title={ __( 'Color' ) }
217
217
  colorSettings={ colorSettings }
218
- />
219
- { ! logosOnly && (
220
- <ContrastChecker
221
- { ...{
222
- textColor: iconColorValue,
223
- backgroundColor: iconBackgroundColorValue,
224
- } }
225
- isLargeText={ false }
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, store as blocksStore } from '@wordpress/blocks';
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 listBlockExists = useSelect(
61
- ( select ) => !! select( blocksStore ).getBlockType( 'core/list' ),
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
- content: stripHTML( headingAttributes.content ),
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 = listBlockExists && (
232
+ const toolbarControls = canInsertList && (
220
233
  <BlockControls>
221
234
  <ToolbarGroup>
222
235
  <ToolbarButton