@wordpress/block-library 9.28.0 → 9.29.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 (196) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/build/accordion/edit.js +123 -0
  3. package/build/accordion/edit.js.map +1 -0
  4. package/build/accordion/icon.js +33 -0
  5. package/build/accordion/icon.js.map +1 -0
  6. package/build/accordion/index.js +100 -0
  7. package/build/accordion/index.js.map +1 -0
  8. package/build/accordion/init.js +12 -0
  9. package/build/accordion/init.js.map +1 -0
  10. package/build/accordion/save.js +36 -0
  11. package/build/accordion/save.js.map +1 -0
  12. package/build/accordion/view.js +49 -0
  13. package/build/accordion/view.js.map +1 -0
  14. package/build/accordion-content/edit.js +129 -0
  15. package/build/accordion-content/edit.js.map +1 -0
  16. package/build/accordion-content/icon.js +35 -0
  17. package/build/accordion-content/icon.js.map +1 -0
  18. package/build/accordion-content/icons.js +30 -0
  19. package/build/accordion-content/icons.js.map +1 -0
  20. package/build/accordion-content/index.js +76 -0
  21. package/build/accordion-content/index.js.map +1 -0
  22. package/build/accordion-content/init.js +12 -0
  23. package/build/accordion-content/init.js.map +1 -0
  24. package/build/accordion-content/save.js +37 -0
  25. package/build/accordion-content/save.js.map +1 -0
  26. package/build/accordion-header/edit.js +118 -0
  27. package/build/accordion-header/edit.js.map +1 -0
  28. package/build/accordion-header/icon.js +25 -0
  29. package/build/accordion-header/icon.js.map +1 -0
  30. package/build/accordion-header/index.js +121 -0
  31. package/build/accordion-header/index.js.map +1 -0
  32. package/build/accordion-header/init.js +12 -0
  33. package/build/accordion-header/init.js.map +1 -0
  34. package/build/accordion-header/save.js +81 -0
  35. package/build/accordion-header/save.js.map +1 -0
  36. package/build/accordion-panel/edit.js +59 -0
  37. package/build/accordion-panel/edit.js.map +1 -0
  38. package/build/accordion-panel/icon.js +22 -0
  39. package/build/accordion-panel/icon.js.map +1 -0
  40. package/build/accordion-panel/index.js +105 -0
  41. package/build/accordion-panel/index.js.map +1 -0
  42. package/build/accordion-panel/init.js +12 -0
  43. package/build/accordion-panel/init.js.map +1 -0
  44. package/build/accordion-panel/save.js +46 -0
  45. package/build/accordion-panel/save.js.map +1 -0
  46. package/build/cover/index.js +2 -1
  47. package/build/cover/index.js.map +1 -1
  48. package/build/freeform/edit.js +6 -0
  49. package/build/freeform/edit.js.map +1 -1
  50. package/build/index.js +10 -0
  51. package/build/index.js.map +1 -1
  52. package/build/media-text/media-container.js +2 -1
  53. package/build/media-text/media-container.js.map +1 -1
  54. package/build/media-text/transforms.js +7 -3
  55. package/build/media-text/transforms.js.map +1 -1
  56. package/build/post-comments-link/edit.js +6 -1
  57. package/build/post-comments-link/edit.js.map +1 -1
  58. package/build/query-title/edit.js +52 -2
  59. package/build/query-title/edit.js.map +1 -1
  60. package/build/query-title/index.js +1 -0
  61. package/build/query-title/index.js.map +1 -1
  62. package/build/query-title/use-post-type-label.js +42 -0
  63. package/build/query-title/use-post-type-label.js.map +1 -0
  64. package/build/query-title/variations.js +10 -0
  65. package/build/query-title/variations.js.map +1 -1
  66. package/build/site-logo/edit.js +56 -41
  67. package/build/site-logo/edit.js.map +1 -1
  68. package/build/site-title/edit.js +9 -3
  69. package/build/site-title/edit.js.map +1 -1
  70. package/build/video/edit-common-settings.js +6 -3
  71. package/build/video/edit-common-settings.js.map +1 -1
  72. package/build-module/accordion/edit.js +116 -0
  73. package/build-module/accordion/edit.js.map +1 -0
  74. package/build-module/accordion/icon.js +27 -0
  75. package/build-module/accordion/icon.js.map +1 -0
  76. package/build-module/accordion/index.js +92 -0
  77. package/build-module/accordion/index.js.map +1 -0
  78. package/build-module/accordion/init.js +6 -0
  79. package/build-module/accordion/init.js.map +1 -0
  80. package/build-module/accordion/save.js +27 -0
  81. package/build-module/accordion/save.js.map +1 -0
  82. package/build-module/accordion/view.js +46 -0
  83. package/build-module/accordion/view.js.map +1 -0
  84. package/build-module/accordion-content/edit.js +120 -0
  85. package/build-module/accordion-content/edit.js.map +1 -0
  86. package/build-module/accordion-content/icon.js +29 -0
  87. package/build-module/accordion-content/icon.js.map +1 -0
  88. package/build-module/accordion-content/icons.js +22 -0
  89. package/build-module/accordion-content/icons.js.map +1 -0
  90. package/build-module/accordion-content/index.js +68 -0
  91. package/build-module/accordion-content/index.js.map +1 -0
  92. package/build-module/accordion-content/init.js +6 -0
  93. package/build-module/accordion-content/init.js.map +1 -0
  94. package/build-module/accordion-content/save.js +28 -0
  95. package/build-module/accordion-content/save.js.map +1 -0
  96. package/build-module/accordion-header/edit.js +108 -0
  97. package/build-module/accordion-header/edit.js.map +1 -0
  98. package/build-module/accordion-header/icon.js +19 -0
  99. package/build-module/accordion-header/icon.js.map +1 -0
  100. package/build-module/accordion-header/index.js +113 -0
  101. package/build-module/accordion-header/index.js.map +1 -0
  102. package/build-module/accordion-header/init.js +6 -0
  103. package/build-module/accordion-header/init.js.map +1 -0
  104. package/build-module/accordion-header/save.js +71 -0
  105. package/build-module/accordion-header/save.js.map +1 -0
  106. package/build-module/accordion-panel/edit.js +50 -0
  107. package/build-module/accordion-panel/edit.js.map +1 -0
  108. package/build-module/accordion-panel/icon.js +16 -0
  109. package/build-module/accordion-panel/icon.js.map +1 -0
  110. package/build-module/accordion-panel/index.js +97 -0
  111. package/build-module/accordion-panel/index.js.map +1 -0
  112. package/build-module/accordion-panel/init.js +6 -0
  113. package/build-module/accordion-panel/init.js.map +1 -0
  114. package/build-module/accordion-panel/save.js +37 -0
  115. package/build-module/accordion-panel/save.js.map +1 -0
  116. package/build-module/cover/index.js +2 -1
  117. package/build-module/cover/index.js.map +1 -1
  118. package/build-module/freeform/edit.js +6 -0
  119. package/build-module/freeform/edit.js.map +1 -1
  120. package/build-module/index.js +10 -0
  121. package/build-module/index.js.map +1 -1
  122. package/build-module/media-text/media-container.js +2 -1
  123. package/build-module/media-text/media-container.js.map +1 -1
  124. package/build-module/media-text/transforms.js +7 -3
  125. package/build-module/media-text/transforms.js.map +1 -1
  126. package/build-module/post-comments-link/edit.js +6 -1
  127. package/build-module/post-comments-link/edit.js.map +1 -1
  128. package/build-module/query-title/edit.js +52 -2
  129. package/build-module/query-title/edit.js.map +1 -1
  130. package/build-module/query-title/index.js +1 -0
  131. package/build-module/query-title/index.js.map +1 -1
  132. package/build-module/query-title/use-post-type-label.js +36 -0
  133. package/build-module/query-title/use-post-type-label.js.map +1 -0
  134. package/build-module/query-title/variations.js +10 -0
  135. package/build-module/query-title/variations.js.map +1 -1
  136. package/build-module/site-logo/edit.js +57 -42
  137. package/build-module/site-logo/edit.js.map +1 -1
  138. package/build-module/site-title/edit.js +10 -4
  139. package/build-module/site-title/edit.js.map +1 -1
  140. package/build-module/video/edit-common-settings.js +6 -3
  141. package/build-module/video/edit-common-settings.js.map +1 -1
  142. package/build-style/accordion/style-rtl.css +223 -0
  143. package/build-style/accordion/style.css +223 -0
  144. package/build-style/style-rtl.css +88 -0
  145. package/build-style/style.css +88 -0
  146. package/package.json +36 -35
  147. package/src/accordion/block.json +69 -0
  148. package/src/accordion/edit.js +133 -0
  149. package/src/accordion/icon.js +23 -0
  150. package/src/accordion/index.js +21 -0
  151. package/src/accordion/index.php +61 -0
  152. package/src/accordion/init.js +6 -0
  153. package/src/accordion/save.js +23 -0
  154. package/src/accordion/style.scss +91 -0
  155. package/src/accordion/view.js +38 -0
  156. package/src/accordion-content/block.json +45 -0
  157. package/src/accordion-content/edit.js +149 -0
  158. package/src/accordion-content/icon.js +28 -0
  159. package/src/accordion-content/icons.js +23 -0
  160. package/src/accordion-content/index.js +21 -0
  161. package/src/accordion-content/index.php +73 -0
  162. package/src/accordion-content/init.js +6 -0
  163. package/src/accordion-content/save.js +25 -0
  164. package/src/accordion-header/block.json +93 -0
  165. package/src/accordion-header/edit.js +131 -0
  166. package/src/accordion-header/icon.js +16 -0
  167. package/src/accordion-header/index.js +21 -0
  168. package/src/accordion-header/init.js +6 -0
  169. package/src/accordion-header/save.js +79 -0
  170. package/src/accordion-panel/block.json +74 -0
  171. package/src/accordion-panel/edit.js +61 -0
  172. package/src/accordion-panel/icon.js +15 -0
  173. package/src/accordion-panel/index.js +21 -0
  174. package/src/accordion-panel/init.js +6 -0
  175. package/src/accordion-panel/save.js +51 -0
  176. package/src/block/index.php +16 -14
  177. package/src/cover/block.json +2 -1
  178. package/src/file/index.php +28 -22
  179. package/src/freeform/edit.js +7 -0
  180. package/src/index.js +12 -0
  181. package/src/media-text/media-container.js +1 -0
  182. package/src/media-text/transforms.js +5 -1
  183. package/src/navigation/edit/test/navigation-menu-selector.js +2 -2
  184. package/src/post-comments-link/edit.js +7 -1
  185. package/src/post-excerpt/index.php +16 -12
  186. package/src/query-title/block.json +1 -0
  187. package/src/query-title/edit.js +58 -1
  188. package/src/query-title/index.php +30 -5
  189. package/src/query-title/use-post-type-label.js +34 -0
  190. package/src/query-title/variations.js +13 -0
  191. package/src/site-logo/edit.js +33 -12
  192. package/src/site-title/edit.js +24 -16
  193. package/src/social-link/README.md +4 -1
  194. package/src/social-link/index.php +1 -1
  195. package/src/style.scss +1 -0
  196. package/src/video/edit-common-settings.js +14 -5
@@ -0,0 +1,74 @@
1
+ {
2
+ "$schema": "https://schemas.wp.org/trunk/block.json",
3
+ "apiVersion": 3,
4
+ "name": "core/accordion-panel",
5
+ "version": "0.1.0",
6
+ "title": "Accordion Panel",
7
+ "category": "design",
8
+ "description": "Displays an accordion panel.",
9
+ "example": {},
10
+ "__experimental": true,
11
+ "parent": [ "core/accordion-content" ],
12
+ "supports": {
13
+ "color": {
14
+ "background": true,
15
+ "gradient": true
16
+ },
17
+ "border": true,
18
+ "interactivity": true,
19
+ "spacing": {
20
+ "padding": true,
21
+ "margin": [ "top", "bottom" ],
22
+ "blockGap": true,
23
+ "__experimentalDefaultControls": {
24
+ "padding": true,
25
+ "blockGap": true
26
+ }
27
+ },
28
+ "__experimentalBorder": {
29
+ "color": true,
30
+ "radius": true,
31
+ "style": true,
32
+ "width": true,
33
+ "__experimentalDefaultControls": {
34
+ "color": true,
35
+ "radius": true,
36
+ "style": true,
37
+ "width": true
38
+ }
39
+ },
40
+ "typography": {
41
+ "fontSize": true,
42
+ "lineHeight": true,
43
+ "__experimentalFontFamily": true,
44
+ "__experimentalFontWeight": true,
45
+ "__experimentalFontStyle": true,
46
+ "__experimentalTextTransform": true,
47
+ "__experimentalTextDecoration": true,
48
+ "__experimentalLetterSpacing": true,
49
+ "__experimentalDefaultControls": {
50
+ "fontSize": true
51
+ }
52
+ },
53
+ "shadow": true
54
+ },
55
+ "attributes": {
56
+ "allowedBlocks": {
57
+ "type": "array"
58
+ },
59
+ "templateLock": {
60
+ "type": [ "string", "boolean" ],
61
+ "enum": [ "all", "insert", "contentOnly", false ],
62
+ "default": false
63
+ },
64
+ "openByDefault": {
65
+ "type": "boolean",
66
+ "default": false
67
+ },
68
+ "isSelected": {
69
+ "type": "boolean",
70
+ "default": false
71
+ }
72
+ },
73
+ "textdomain": "default"
74
+ }
@@ -0,0 +1,61 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import {
5
+ useBlockProps,
6
+ useInnerBlocksProps,
7
+ __experimentalUseBorderProps as useBorderProps,
8
+ __experimentalUseColorProps as useColorProps,
9
+ __experimentalGetSpacingClassesAndStyles as useSpacingProps,
10
+ __experimentalGetShadowClassesAndStyles as useShadowProps,
11
+ } from '@wordpress/block-editor';
12
+ /**
13
+ * External dependencies
14
+ */
15
+ import clsx from 'clsx';
16
+
17
+ export default function Edit( { attributes } ) {
18
+ const { allowedBlocks, templateLock, openByDefault, isSelected } =
19
+ attributes;
20
+ const borderProps = useBorderProps( attributes );
21
+ const colorProps = useColorProps( attributes );
22
+ const spacingProps = useSpacingProps( attributes );
23
+ const shadowProps = useShadowProps( attributes );
24
+
25
+ const blockProps = useBlockProps();
26
+ const innerBlocksProps = useInnerBlocksProps(
27
+ {
28
+ className: 'accordion-content__wrapper',
29
+ style: {
30
+ ...spacingProps.style,
31
+ },
32
+ },
33
+ {
34
+ allowedBlocks,
35
+ template: [ [ 'core/paragraph', {} ] ],
36
+ templateLock,
37
+ }
38
+ );
39
+
40
+ return (
41
+ <div
42
+ { ...blockProps }
43
+ className={ clsx(
44
+ blockProps.className,
45
+ colorProps.className,
46
+ borderProps.className,
47
+ {
48
+ [ `has-custom-font-size` ]: blockProps?.style?.fontSize,
49
+ }
50
+ ) }
51
+ style={ {
52
+ ...borderProps.style,
53
+ ...colorProps.style,
54
+ ...shadowProps.style,
55
+ } }
56
+ aria-hidden={ ! isSelected && ! openByDefault }
57
+ >
58
+ <div { ...innerBlocksProps } />
59
+ </div>
60
+ );
61
+ }
@@ -0,0 +1,15 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import { SVG, Path } from '@wordpress/primitives';
5
+
6
+ export default (
7
+ <SVG xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
8
+ <Path
9
+ fillRule="evenodd"
10
+ clipRule="evenodd"
11
+ d="M8.10417 6.00024H6.5C5.39543 6.00024 4.5 6.89567 4.5 8.00024V10.3336H6V8.00024C6 7.7241 6.22386 7.50024 6.5 7.50024H8.10417V6.00024ZM4.5 13.6669V16.0002C4.5 17.1048 5.39543 18.0002 6.5 18.0002H8.10417V16.5002H6.5C6.22386 16.5002 6 16.2764 6 16.0002V13.6669H4.5ZM10.3958 6.00024V7.50024H13.6042V6.00024H10.3958ZM15.8958 6.00024V7.50024H17.5C17.7761 7.50024 18 7.7241 18 8.00024V10.3336H19.5V8.00024C19.5 6.89567 18.6046 6.00024 17.5 6.00024H15.8958ZM19.5 13.6669H18V16.0002C18 16.2764 17.7761 16.5002 17.5 16.5002H15.8958V18.0002H17.5C18.6046 18.0002 19.5 17.1048 19.5 16.0002V13.6669ZM13.6042 18.0002V16.5002H10.3958V18.0002H13.6042Z"
12
+ fill="currentColor"
13
+ />
14
+ </SVG>
15
+ );
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Internal dependencies
3
+ */
4
+ import edit from './edit';
5
+ import save from './save';
6
+ import metadata from './block.json';
7
+ import initBlock from '../utils/init-block';
8
+ import icon from './icon';
9
+
10
+ const { name } = metadata;
11
+
12
+ export { metadata, name };
13
+
14
+ export const settings = {
15
+ icon,
16
+ example: {},
17
+ edit,
18
+ save,
19
+ };
20
+
21
+ export const init = () => initBlock( { name, metadata, settings } );
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Internal dependencies
3
+ */
4
+ import { init } from './';
5
+
6
+ export default init();
@@ -0,0 +1,51 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import {
5
+ InnerBlocks,
6
+ useBlockProps,
7
+ __experimentalGetBorderClassesAndStyles as getBorderClassesAndStyles,
8
+ __experimentalGetColorClassesAndStyles as getColorClassesAndStyles,
9
+ __experimentalGetSpacingClassesAndStyles as getSpacingClassesAndStyles,
10
+ __experimentalGetShadowClassesAndStyles as getShadowClassesAndStyles,
11
+ } from '@wordpress/block-editor';
12
+ /**
13
+ * External dependencies
14
+ */
15
+ import clsx from 'clsx';
16
+
17
+ export default function save( { attributes } ) {
18
+ const blockProps = useBlockProps.save();
19
+ const borderProps = getBorderClassesAndStyles( attributes );
20
+ const colorProps = getColorClassesAndStyles( attributes );
21
+ const spacingProps = getSpacingClassesAndStyles( attributes );
22
+ const shadowProps = getShadowClassesAndStyles( attributes );
23
+
24
+ return (
25
+ <div
26
+ { ...blockProps }
27
+ className={ clsx(
28
+ blockProps.className,
29
+ colorProps.className,
30
+ borderProps.className,
31
+ {
32
+ [ `has-custom-font-size` ]: blockProps?.style?.fontSize,
33
+ }
34
+ ) }
35
+ style={ {
36
+ ...borderProps.style,
37
+ ...colorProps.style,
38
+ ...shadowProps.style,
39
+ } }
40
+ >
41
+ <div
42
+ className="accordion-content__wrapper"
43
+ style={ {
44
+ ...spacingProps.style,
45
+ } }
46
+ >
47
+ <InnerBlocks.Content />
48
+ </div>
49
+ </div>
50
+ );
51
+ }
@@ -88,20 +88,22 @@ function render_block_core_block( $attributes, $content, $block_instance ) {
88
88
  $block_instance->refresh_context_dependents();
89
89
  } else {
90
90
  // This branch can be removed once Gutenberg requires WordPress 6.8 or later.
91
- // phpcs:ignore Gutenberg.Commenting.SinceTag.MissingClassSinceTag
92
- class WP_Block_Cloner extends WP_Block {
93
- /**
94
- * Static methods of subclasses have access to protected properties
95
- * of instances of the parent class.
96
- * In this case, this gives us access to `available_context` and `registry`.
97
- */
98
- // phpcs:ignore Gutenberg.Commenting.SinceTag.MissingMethodSinceTag
99
- public static function clone_instance( $instance ) {
100
- return new WP_Block(
101
- $instance->parsed_block,
102
- $instance->available_context,
103
- $instance->registry
104
- );
91
+ if ( ! class_exists( 'WP_Block_Cloner' ) ) {
92
+ // phpcs:ignore Gutenberg.Commenting.SinceTag.MissingClassSinceTag
93
+ class WP_Block_Cloner extends WP_Block {
94
+ /**
95
+ * Static methods of subclasses have access to protected properties
96
+ * of instances of the parent class.
97
+ * In this case, this gives us access to `available_context` and `registry`.
98
+ */
99
+ // phpcs:ignore Gutenberg.Commenting.SinceTag.MissingMethodSinceTag
100
+ public static function clone_instance( $instance ) {
101
+ return new WP_Block(
102
+ $instance->parsed_block,
103
+ $instance->available_context,
104
+ $instance->registry
105
+ );
106
+ }
105
107
  }
106
108
  }
107
109
  $block_instance = WP_Block_Cloner::clone_instance( $block_instance );
@@ -8,7 +8,8 @@
8
8
  "textdomain": "default",
9
9
  "attributes": {
10
10
  "url": {
11
- "type": "string"
11
+ "type": "string",
12
+ "role": "content"
12
13
  },
13
14
  "useFeaturedImage": {
14
15
  "type": "boolean",
@@ -16,33 +16,39 @@
16
16
  * @return string Returns the block content.
17
17
  */
18
18
  function render_block_core_file( $attributes, $content ) {
19
+ if ( empty( $attributes['displayPreview'] ) ) {
20
+ return $content;
21
+ }
22
+
19
23
  // If it's interactive, enqueue the script module and add the directives.
20
- if ( ! empty( $attributes['displayPreview'] ) ) {
21
- wp_enqueue_script_module( '@wordpress/block-library/file/view' );
24
+ wp_enqueue_script_module( '@wordpress/block-library/file/view' );
22
25
 
23
- $processor = new WP_HTML_Tag_Processor( $content );
24
- $processor->next_tag();
26
+ $processor = new WP_HTML_Tag_Processor( $content );
27
+ if ( $processor->next_tag() ) {
25
28
  $processor->set_attribute( 'data-wp-interactive', 'core/file' );
26
- $processor->next_tag( 'object' );
27
- $processor->set_attribute( 'data-wp-bind--hidden', '!state.hasPdfPreview' );
28
- $processor->set_attribute( 'hidden', true );
29
-
30
- $filename = $processor->get_attribute( 'aria-label' );
31
- $has_filename = ! empty( $filename ) && 'PDF embed' !== $filename;
32
- $label = $has_filename ? sprintf(
33
- /* translators: %s: filename. */
34
- __( 'Embed of %s.' ),
35
- $filename
36
- ) : __( 'PDF embed' );
37
-
38
- // Update object's aria-label attribute if present in block HTML.
39
- // Match an aria-label attribute from an object tag.
40
- $processor->set_attribute( 'aria-label', $label );
41
-
42
- return $processor->get_updated_html();
43
29
  }
44
30
 
45
- return $content;
31
+ // If there are no OBJECT elements, something might have already modified the block.
32
+ if ( ! $processor->next_tag( 'OBJECT' ) ) {
33
+ return $content;
34
+ }
35
+
36
+ $processor->set_attribute( 'data-wp-bind--hidden', '!state.hasPdfPreview' );
37
+ $processor->set_attribute( 'hidden', true );
38
+
39
+ $filename = $processor->get_attribute( 'aria-label' );
40
+ $has_filename = is_string( $filename ) && ! empty( $filename ) && 'PDF embed' !== $filename;
41
+ $label = $has_filename ? sprintf(
42
+ /* translators: %s: filename. */
43
+ __( 'Embed of %s.' ),
44
+ $filename
45
+ ) : __( 'PDF embed' );
46
+
47
+ // Update object's aria-label attribute if present in block HTML.
48
+ // Match an aria-label attribute from an object tag.
49
+ $processor->set_attribute( 'aria-label', $label );
50
+
51
+ return $processor->get_updated_html();
46
52
  }
47
53
 
48
54
  /**
@@ -188,6 +188,13 @@ function ClassicEdit( {
188
188
  }
189
189
  } );
190
190
 
191
+ editor.on( 'paste', ( event ) => {
192
+ // TinyMCE selection isn’t synced with the block editor selection store.
193
+ // This event handler prevents paste from bubbling so the useClipboardHandler
194
+ // won’t replace the block.
195
+ event.stopPropagation();
196
+ } );
197
+
191
198
  editor.on( 'init', () => {
192
199
  const rootNode = editor.getBody();
193
200
 
package/src/index.js CHANGED
@@ -20,6 +20,10 @@ import {
20
20
  // production build to make the final bundle smaller.
21
21
  //
22
22
  // See https://github.com/WordPress/gutenberg/pull/40655 for more context.
23
+ import * as accordion from './accordion';
24
+ import * as accordionContent from './accordion-content';
25
+ import * as accordionHeader from './accordion-header';
26
+ import * as accordionPanel from './accordion-panel';
23
27
  import * as archives from './archives';
24
28
  import * as avatar from './avatar';
25
29
  import * as audio from './audio';
@@ -234,6 +238,14 @@ const getAllBlocks = () => {
234
238
  queryTitle,
235
239
  postAuthorBiography,
236
240
  ];
241
+
242
+ if ( window?.__experimentalEnableBlockExperiments ) {
243
+ blocks.push( accordion );
244
+ blocks.push( accordionContent );
245
+ blocks.push( accordionHeader );
246
+ blocks.push( accordionPanel );
247
+ }
248
+
237
249
  if ( window?.__experimentalEnableFormBlocks ) {
238
250
  blocks.push( form );
239
251
  blocks.push( formInput );
@@ -200,6 +200,7 @@ function MediaContainer( props, ref ) {
200
200
  }
201
201
  mediaId={ mediaId }
202
202
  toggleUseFeaturedImage={ toggleUseFeaturedImage }
203
+ useFeaturedImage={ useFeaturedImage }
203
204
  />
204
205
  { ( mediaTypeRenderers[ mediaType ] || noop )() }
205
206
  { isTemporaryMedia && <Spinner /> }
@@ -45,6 +45,7 @@ const transforms = {
45
45
  style,
46
46
  textColor,
47
47
  url,
48
+ useFeaturedImage,
48
49
  },
49
50
  innerBlocks
50
51
  ) => {
@@ -90,6 +91,7 @@ const transforms = {
90
91
  mediaType: backgroundType,
91
92
  mediaUrl: url,
92
93
  textColor,
94
+ useFeaturedImage,
93
95
  ...additionalAttributes,
94
96
  },
95
97
  innerBlocks
@@ -143,6 +145,7 @@ const transforms = {
143
145
  mediaUrl,
144
146
  style,
145
147
  textColor,
148
+ useFeaturedImage,
146
149
  },
147
150
  innerBlocks
148
151
  ) => {
@@ -169,13 +172,14 @@ const transforms = {
169
172
  alt: mediaAlt,
170
173
  anchor,
171
174
  backgroundType: mediaType,
172
- dimRatio: !! mediaUrl ? 50 : 100,
175
+ dimRatio: !! mediaUrl || useFeaturedImage ? 50 : 100,
173
176
  focalPoint,
174
177
  gradient,
175
178
  id: mediaId,
176
179
  overlayColor: backgroundColor,
177
180
  textColor,
178
181
  url: mediaUrl,
182
+ useFeaturedImage,
179
183
  ...additionalAttributes,
180
184
  };
181
185
 
@@ -295,7 +295,7 @@ describe( 'NavigationMenuSelector', () => {
295
295
  screen.queryByRole( 'menuitem', {
296
296
  name: 'Create new Menu',
297
297
  } )
298
- ).toBeDisabled();
298
+ ).toHaveAttribute( 'aria-disabled', 'true' );
299
299
 
300
300
  // once the menu is created
301
301
  // no more network activity to wait on
@@ -619,7 +619,7 @@ describe( 'NavigationMenuSelector', () => {
619
619
  // Check all menu items are present but disabled.
620
620
  screen.getAllByRole( 'menuitem' ).forEach( ( item ) => {
621
621
  // // Check all menu items are present but disabled.
622
- expect( item ).toBeDisabled();
622
+ expect( item ).toHaveAttribute( 'aria-disabled', 'true' );
623
623
  } );
624
624
 
625
625
  // once the menu is imported
@@ -60,7 +60,13 @@ function PostCommentsLinkEdit( { context, attributes, setAttributes } ) {
60
60
  );
61
61
 
62
62
  if ( ! post ) {
63
- return null;
63
+ return (
64
+ <div { ...blockProps }>
65
+ <Warning>
66
+ { __( 'Post Comments Link block: post not found.' ) }
67
+ </Warning>
68
+ </div>
69
+ );
64
70
  }
65
71
 
66
72
  const { link } = post;
@@ -20,18 +20,6 @@ function render_block_core_post_excerpt( $attributes, $content, $block ) {
20
20
  return '';
21
21
  }
22
22
 
23
- /*
24
- * The purpose of the excerpt length setting is to limit the length of both
25
- * automatically generated and user-created excerpts.
26
- * Because the excerpt_length filter only applies to auto generated excerpts,
27
- * wp_trim_words is used instead.
28
- */
29
- $excerpt_length = $attributes['excerptLength'];
30
- $excerpt = get_the_excerpt( $block->context['postId'] );
31
- if ( isset( $excerpt_length ) ) {
32
- $excerpt = wp_trim_words( $excerpt, $excerpt_length );
33
- }
34
-
35
23
  $more_text = ! empty( $attributes['moreText'] ) ? '<a class="wp-block-post-excerpt__more-link" href="' . esc_url( get_the_permalink( $block->context['postId'] ) ) . '">' . wp_kses_post( $attributes['moreText'] ) . '</a>' : '';
36
24
  $filter_excerpt_more = static function ( $more ) use ( $more_text ) {
37
25
  return empty( $more_text ) ? $more : '';
@@ -44,8 +32,24 @@ function render_block_core_post_excerpt( $attributes, $content, $block ) {
44
32
  * So if the block's attribute is not empty override the
45
33
  * `excerpt_more` filter and return nothing. This will
46
34
  * result in showing only one `read more` link at a time.
35
+ *
36
+ * This hook needs to be applied before the excerpt is retrieved with get_the_excerpt.
37
+ * Otherwise, the read more link filter from the theme is not removed.
47
38
  */
48
39
  add_filter( 'excerpt_more', $filter_excerpt_more );
40
+
41
+ /*
42
+ * The purpose of the excerpt length setting is to limit the length of both
43
+ * automatically generated and user-created excerpts.
44
+ * Because the excerpt_length filter only applies to auto generated excerpts,
45
+ * wp_trim_words is used instead.
46
+ */
47
+ $excerpt_length = $attributes['excerptLength'];
48
+ $excerpt = get_the_excerpt( $block->context['postId'] );
49
+ if ( isset( $excerpt_length ) ) {
50
+ $excerpt = wp_trim_words( $excerpt, $excerpt_length );
51
+ }
52
+
49
53
  $classes = array();
50
54
  if ( isset( $attributes['textAlign'] ) ) {
51
55
  $classes[] = 'has-text-align-' . $attributes['textAlign'];
@@ -34,6 +34,7 @@
34
34
  "type": "search"
35
35
  }
36
36
  },
37
+ "usesContext": [ "query" ],
37
38
  "supports": {
38
39
  "align": [ "wide", "full" ],
39
40
  "html": false,
@@ -25,9 +25,10 @@ import { __, _x, sprintf } from '@wordpress/i18n';
25
25
  * Internal dependencies
26
26
  */
27
27
  import { useArchiveLabel } from './use-archive-label';
28
+ import { usePostTypeLabel } from './use-post-type-label';
28
29
  import { useToolsPanelDropdownMenuProps } from '../utils/hooks';
29
30
 
30
- const SUPPORTED_TYPES = [ 'archive', 'search' ];
31
+ const SUPPORTED_TYPES = [ 'archive', 'search', 'post-type' ];
31
32
 
32
33
  export default function QueryTitleEdit( {
33
34
  attributes: {
@@ -39,8 +40,10 @@ export default function QueryTitleEdit( {
39
40
  showSearchTerm,
40
41
  },
41
42
  setAttributes,
43
+ context: { query },
42
44
  } ) {
43
45
  const { archiveTypeLabel, archiveNameLabel } = useArchiveLabel();
46
+ const { postTypeLabel } = usePostTypeLabel( query?.postType );
44
47
  const dropdownMenuProps = useToolsPanelDropdownMenuProps();
45
48
 
46
49
  const TagName = `h${ level }`;
@@ -174,6 +177,60 @@ export default function QueryTitleEdit( {
174
177
  );
175
178
  }
176
179
 
180
+ if ( type === 'post-type' ) {
181
+ let title;
182
+ if ( postTypeLabel ) {
183
+ if ( showPrefix ) {
184
+ title = sprintf(
185
+ /* translators: %s: Singular post type name of the queried object */
186
+ __( 'Post Type: "%s"' ),
187
+ postTypeLabel
188
+ );
189
+ } else {
190
+ title = postTypeLabel;
191
+ }
192
+ } else {
193
+ title = showPrefix ? __( 'Post Type: Name' ) : __( 'Name' );
194
+ }
195
+
196
+ titleElement = (
197
+ <>
198
+ <InspectorControls>
199
+ <ToolsPanel
200
+ label={ __( 'Settings' ) }
201
+ resetAll={ () =>
202
+ setAttributes( {
203
+ showPrefix: true,
204
+ } )
205
+ }
206
+ dropdownMenuProps={ dropdownMenuProps }
207
+ >
208
+ <ToolsPanelItem
209
+ hasValue={ () => ! showPrefix }
210
+ label={ __( 'Show post type label' ) }
211
+ onDeselect={ () =>
212
+ setAttributes( { showPrefix: true } )
213
+ }
214
+ isShownByDefault
215
+ >
216
+ <ToggleControl
217
+ __nextHasNoMarginBottom
218
+ label={ __( 'Show post type label' ) }
219
+ onChange={ () =>
220
+ setAttributes( {
221
+ showPrefix: ! showPrefix,
222
+ } )
223
+ }
224
+ checked={ showPrefix }
225
+ />
226
+ </ToolsPanelItem>
227
+ </ToolsPanel>
228
+ </InspectorControls>
229
+ <TagName { ...blockProps }>{ title }</TagName>
230
+ </>
231
+ );
232
+ }
233
+
177
234
  return (
178
235
  <>
179
236
  <BlockControls group="block">
@@ -7,23 +7,28 @@
7
7
 
8
8
  /**
9
9
  * Renders the `core/query-title` block on the server.
10
- * For now it only supports Archive title,
10
+ * For now it supports Archive title, Search title, and Post Type Label,
11
11
  * using queried object information
12
12
  *
13
13
  * @since 5.8.0
14
14
  *
15
- * @param array $attributes Block attributes.
15
+ * @param array $attributes Block attributes.
16
+ * @param array $_content Block content.
17
+ * @param object $block Block instance.
16
18
  *
17
19
  * @return string Returns the query title based on the queried object.
18
20
  */
19
- function render_block_core_query_title( $attributes ) {
21
+ function render_block_core_query_title( $attributes, $content, $block ) {
20
22
  $type = isset( $attributes['type'] ) ? $attributes['type'] : null;
21
23
  $is_archive = is_archive();
22
24
  $is_search = is_search();
25
+ $post_type = isset( $block->context['query']['postType'] ) ? $block->context['query']['postType'] : get_post_type();
26
+
23
27
  if ( ! $type ||
24
28
  ( 'archive' === $type && ! $is_archive ) ||
25
- ( 'search' === $type && ! $is_search )
26
- ) {
29
+ ( 'search' === $type && ! $is_search ) ||
30
+ ( 'post-type' === $type && ! $post_type )
31
+ ) {
27
32
  return '';
28
33
  }
29
34
  $title = '';
@@ -48,6 +53,26 @@ function render_block_core_query_title( $attributes ) {
48
53
  );
49
54
  }
50
55
  }
56
+ if ( 'post-type' === $type ) {
57
+ $post_type_object = get_post_type_object( $post_type );
58
+
59
+ if ( ! $post_type_object ) {
60
+ return '';
61
+ }
62
+
63
+ $post_type_name = $post_type_object->labels->singular_name;
64
+ $show_prefix = isset( $attributes['showPrefix'] ) ? $attributes['showPrefix'] : true;
65
+
66
+ if ( $show_prefix ) {
67
+ $title = sprintf(
68
+ /* translators: %s is the post type name. */
69
+ __( 'Post Type: "%s"' ),
70
+ $post_type_name
71
+ );
72
+ } else {
73
+ $title = $post_type_name;
74
+ }
75
+ }
51
76
 
52
77
  $tag_name = isset( $attributes['level'] ) ? 'h' . (int) $attributes['level'] : 'h1';
53
78
  $align_class_name = empty( $attributes['textAlign'] ) ? '' : "has-text-align-{$attributes['textAlign']}";