@wordpress/block-library 8.22.0 → 8.23.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 (175) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/build/block/edit.js +3 -2
  3. package/build/block/edit.js.map +1 -1
  4. package/build/button/edit.js +57 -2
  5. package/build/button/edit.js.map +1 -1
  6. package/build/code/transforms.js +20 -7
  7. package/build/code/transforms.js.map +1 -1
  8. package/build/comments/edit/comments-inspector-controls.js +1 -0
  9. package/build/comments/edit/comments-inspector-controls.js.map +1 -1
  10. package/build/cover/edit/inspector-controls.js +1 -0
  11. package/build/cover/edit/inspector-controls.js.map +1 -1
  12. package/build/details/edit.js +1 -2
  13. package/build/details/edit.js.map +1 -1
  14. package/build/form/index.js +1 -1
  15. package/build/form/index.js.map +1 -1
  16. package/build/form-submit-button/edit.js +2 -1
  17. package/build/form-submit-button/edit.js.map +1 -1
  18. package/build/gallery/gap-styles.js +12 -7
  19. package/build/gallery/gap-styles.js.map +1 -1
  20. package/build/group/edit.js +1 -0
  21. package/build/group/edit.js.map +1 -1
  22. package/build/html/transforms.js +7 -2
  23. package/build/html/transforms.js.map +1 -1
  24. package/build/image/deprecated.js +8 -0
  25. package/build/image/deprecated.js.map +1 -1
  26. package/build/image/view.js +10 -7
  27. package/build/image/view.js.map +1 -1
  28. package/build/missing/index.js +1 -1
  29. package/build/navigation/edit/overlay-menu-preview.js +1 -1
  30. package/build/navigation/edit/overlay-menu-preview.js.map +1 -1
  31. package/build/navigation/use-template-part-area-label.js +2 -1
  32. package/build/navigation/use-template-part-area-label.js.map +1 -1
  33. package/build/navigation-link/edit.js +1 -1
  34. package/build/navigation-link/edit.js.map +1 -1
  35. package/build/pattern/edit.js +1 -1
  36. package/build/pattern/edit.js.map +1 -1
  37. package/build/post-author/edit.js +0 -1
  38. package/build/post-author/edit.js.map +1 -1
  39. package/build/post-featured-image/edit.js +21 -6
  40. package/build/post-featured-image/edit.js.map +1 -1
  41. package/build/post-template/edit.js +2 -8
  42. package/build/post-template/edit.js.map +1 -1
  43. package/build/post-template/index.js +1 -1
  44. package/build/post-terms/edit.js +0 -2
  45. package/build/post-terms/edit.js.map +1 -1
  46. package/build/preformatted/transforms.js +1 -4
  47. package/build/preformatted/transforms.js.map +1 -1
  48. package/build/query/edit/query-content.js +1 -0
  49. package/build/query/edit/query-content.js.map +1 -1
  50. package/build/quote/index.js +6 -0
  51. package/build/quote/index.js.map +1 -1
  52. package/build/template-part/edit/advanced-controls.js +1 -0
  53. package/build/template-part/edit/advanced-controls.js.map +1 -1
  54. package/build/template-part/edit/index.js +3 -7
  55. package/build/template-part/edit/index.js.map +1 -1
  56. package/build/template-part/index.js +6 -2
  57. package/build/template-part/index.js.map +1 -1
  58. package/build/template-part/variations.js +5 -1
  59. package/build/template-part/variations.js.map +1 -1
  60. package/build-module/block/edit.js +3 -2
  61. package/build-module/block/edit.js.map +1 -1
  62. package/build-module/button/edit.js +61 -6
  63. package/build-module/button/edit.js.map +1 -1
  64. package/build-module/code/transforms.js +20 -7
  65. package/build-module/code/transforms.js.map +1 -1
  66. package/build-module/comments/edit/comments-inspector-controls.js +1 -0
  67. package/build-module/comments/edit/comments-inspector-controls.js.map +1 -1
  68. package/build-module/cover/edit/inspector-controls.js +1 -0
  69. package/build-module/cover/edit/inspector-controls.js.map +1 -1
  70. package/build-module/details/edit.js +1 -2
  71. package/build-module/details/edit.js.map +1 -1
  72. package/build-module/form/index.js +1 -1
  73. package/build-module/form/index.js.map +1 -1
  74. package/build-module/form-submit-button/edit.js +2 -1
  75. package/build-module/form-submit-button/edit.js.map +1 -1
  76. package/build-module/gallery/gap-styles.js +13 -8
  77. package/build-module/gallery/gap-styles.js.map +1 -1
  78. package/build-module/group/edit.js +1 -0
  79. package/build-module/group/edit.js.map +1 -1
  80. package/build-module/html/transforms.js +7 -2
  81. package/build-module/html/transforms.js.map +1 -1
  82. package/build-module/image/deprecated.js +8 -0
  83. package/build-module/image/deprecated.js.map +1 -1
  84. package/build-module/image/view.js +10 -7
  85. package/build-module/image/view.js.map +1 -1
  86. package/build-module/missing/index.js +1 -1
  87. package/build-module/navigation/edit/overlay-menu-preview.js +1 -1
  88. package/build-module/navigation/edit/overlay-menu-preview.js.map +1 -1
  89. package/build-module/navigation/use-template-part-area-label.js +2 -1
  90. package/build-module/navigation/use-template-part-area-label.js.map +1 -1
  91. package/build-module/navigation-link/edit.js +2 -2
  92. package/build-module/navigation-link/edit.js.map +1 -1
  93. package/build-module/pattern/edit.js +1 -1
  94. package/build-module/pattern/edit.js.map +1 -1
  95. package/build-module/post-author/edit.js +0 -1
  96. package/build-module/post-author/edit.js.map +1 -1
  97. package/build-module/post-featured-image/edit.js +21 -6
  98. package/build-module/post-featured-image/edit.js.map +1 -1
  99. package/build-module/post-template/edit.js +2 -8
  100. package/build-module/post-template/edit.js.map +1 -1
  101. package/build-module/post-template/index.js +1 -1
  102. package/build-module/post-terms/edit.js +0 -2
  103. package/build-module/post-terms/edit.js.map +1 -1
  104. package/build-module/preformatted/transforms.js +1 -4
  105. package/build-module/preformatted/transforms.js.map +1 -1
  106. package/build-module/query/edit/query-content.js +1 -0
  107. package/build-module/query/edit/query-content.js.map +1 -1
  108. package/build-module/quote/index.js +6 -0
  109. package/build-module/quote/index.js.map +1 -1
  110. package/build-module/template-part/edit/advanced-controls.js +1 -0
  111. package/build-module/template-part/edit/advanced-controls.js.map +1 -1
  112. package/build-module/template-part/edit/index.js +5 -9
  113. package/build-module/template-part/edit/index.js.map +1 -1
  114. package/build-module/template-part/index.js +6 -2
  115. package/build-module/template-part/index.js.map +1 -1
  116. package/build-module/template-part/variations.js +5 -1
  117. package/build-module/template-part/variations.js.map +1 -1
  118. package/build-style/editor-rtl.css +12 -0
  119. package/build-style/editor.css +12 -0
  120. package/build-style/image/editor-rtl.css +3 -0
  121. package/build-style/image/editor.css +3 -0
  122. package/build-style/image/style-rtl.css +19 -13
  123. package/build-style/image/style.css +19 -13
  124. package/build-style/post-featured-image/editor-rtl.css +9 -0
  125. package/build-style/post-featured-image/editor.css +9 -0
  126. package/build-style/quote/style-rtl.css +3 -0
  127. package/build-style/quote/style.css +3 -0
  128. package/build-style/read-more/style-rtl.css +2 -2
  129. package/build-style/read-more/style.css +2 -2
  130. package/build-style/style-rtl.css +24 -15
  131. package/build-style/style.css +24 -15
  132. package/package.json +32 -32
  133. package/src/block/edit.js +2 -1
  134. package/src/button/edit.js +70 -4
  135. package/src/code/transforms.js +14 -8
  136. package/src/comments/edit/comments-inspector-controls.js +1 -0
  137. package/src/cover/edit/inspector-controls.js +1 -0
  138. package/src/details/edit.js +0 -1
  139. package/src/form/index.js +1 -1
  140. package/src/form-submit-button/edit.js +1 -0
  141. package/src/gallery/gap-styles.js +10 -9
  142. package/src/group/edit.js +1 -0
  143. package/src/html/transforms.js +5 -2
  144. package/src/image/deprecated.js +8 -0
  145. package/src/image/editor.scss +7 -0
  146. package/src/image/index.php +3 -4
  147. package/src/image/style.scss +18 -13
  148. package/src/image/view.js +24 -11
  149. package/src/missing/block.json +1 -1
  150. package/src/navigation/edit/overlay-menu-preview.js +1 -1
  151. package/src/navigation/index.php +37 -402
  152. package/src/navigation/use-template-part-area-label.js +4 -2
  153. package/src/navigation-link/edit.js +2 -2
  154. package/src/navigation-link/index.php +57 -0
  155. package/src/paragraph/test/__snapshots__/transforms.native.js.snap +6 -0
  156. package/src/paragraph/test/transforms.native.js +1 -0
  157. package/src/pattern/edit.js +2 -1
  158. package/src/pattern/index.php +6 -1
  159. package/src/post-author/edit.js +0 -1
  160. package/src/post-featured-image/edit.js +38 -5
  161. package/src/post-featured-image/editor.scss +19 -0
  162. package/src/post-template/block.json +0 -1
  163. package/src/post-template/edit.js +1 -5
  164. package/src/post-terms/edit.js +0 -2
  165. package/src/preformatted/transforms.js +1 -4
  166. package/src/query/edit/query-content.js +1 -0
  167. package/src/query/index.php +6 -2
  168. package/src/quote/block.json +6 -0
  169. package/src/quote/style.scss +4 -0
  170. package/src/read-more/style.scss +1 -1
  171. package/src/template-part/edit/advanced-controls.js +1 -0
  172. package/src/template-part/edit/index.js +7 -14
  173. package/src/template-part/index.js +4 -3
  174. package/src/template-part/index.php +4 -4
  175. package/src/template-part/variations.js +4 -2
@@ -43,6 +43,11 @@ function getMediaSourceUrlBySizeSlug( media, slug ) {
43
43
  );
44
44
  }
45
45
 
46
+ const disabledClickProps = {
47
+ onClick: ( event ) => event.preventDefault(),
48
+ 'aria-disabled': true,
49
+ };
50
+
46
51
  export default function PostFeaturedImageEdit( {
47
52
  clientId,
48
53
  attributes,
@@ -67,9 +72,10 @@ export default function PostFeaturedImageEdit( {
67
72
  postId
68
73
  );
69
74
 
70
- const { media, postType } = useSelect(
75
+ const { media, postType, postPermalink } = useSelect(
71
76
  ( select ) => {
72
- const { getMedia, getPostType } = select( coreStore );
77
+ const { getMedia, getPostType, getEditedEntityRecord } =
78
+ select( coreStore );
73
79
  return {
74
80
  media:
75
81
  featuredImage &&
@@ -77,10 +83,16 @@ export default function PostFeaturedImageEdit( {
77
83
  context: 'view',
78
84
  } ),
79
85
  postType: postTypeSlug && getPostType( postTypeSlug ),
86
+ postPermalink: getEditedEntityRecord(
87
+ 'postType',
88
+ postTypeSlug,
89
+ postId
90
+ )?.link,
80
91
  };
81
92
  },
82
- [ featuredImage, postTypeSlug ]
93
+ [ featuredImage, postTypeSlug, postId ]
83
94
  );
95
+
84
96
  const mediaUrl = getMediaSourceUrlBySizeSlug( media, sizeSlug );
85
97
 
86
98
  const imageSizes = useSelect(
@@ -197,7 +209,17 @@ export default function PostFeaturedImageEdit( {
197
209
  <>
198
210
  { controls }
199
211
  <div { ...blockProps }>
200
- { placeholder() }
212
+ { !! isLink ? (
213
+ <a
214
+ href={ postPermalink }
215
+ target={ linkTarget }
216
+ { ...disabledClickProps }
217
+ >
218
+ { placeholder() }
219
+ </a>
220
+ ) : (
221
+ placeholder()
222
+ ) }
201
223
  <Overlay
202
224
  attributes={ attributes }
203
225
  setAttributes={ setAttributes }
@@ -295,7 +317,18 @@ export default function PostFeaturedImageEdit( {
295
317
  </BlockControls>
296
318
  ) }
297
319
  <figure { ...blockProps }>
298
- { image }
320
+ { /* If the featured image is linked, wrap in an <a /> tag to trigger any inherited link element styles */ }
321
+ { !! isLink ? (
322
+ <a
323
+ href={ postPermalink }
324
+ target={ linkTarget }
325
+ { ...disabledClickProps }
326
+ >
327
+ { image }
328
+ </a>
329
+ ) : (
330
+ image
331
+ ) }
299
332
  <Overlay
300
333
  attributes={ attributes }
301
334
  setAttributes={ setAttributes }
@@ -96,6 +96,25 @@
96
96
  height: 100%;
97
97
  width: 100%;
98
98
  }
99
+
100
+ // When the Post Featured Image block is linked,
101
+ // it's wrapped with a disabled <a /> tag.
102
+ // Restore cursor style so it doesn't appear 'clickable'.
103
+ > a {
104
+ cursor: default;
105
+ }
106
+
107
+ // When the Post Featured Image block is linked,
108
+ // and wrapped with a disabled <a /> tag
109
+ // ensure that the placeholder items are visible when selected.
110
+ &.is-selected .components-placeholder.has-illustration {
111
+ .components-button,
112
+ .components-placeholder__instructions,
113
+ .components-placeholder__label {
114
+ opacity: 1;
115
+ pointer-events: auto;
116
+ }
117
+ }
99
118
  }
100
119
 
101
120
  div[data-type="core/post-featured-image"] {
@@ -10,7 +10,6 @@
10
10
  "usesContext": [
11
11
  "queryId",
12
12
  "query",
13
- "queryContext",
14
13
  "displayLayout",
15
14
  "templateSlug",
16
15
  "previewPostType",
@@ -96,7 +96,6 @@ export default function PostTemplateEdit( {
96
96
  // REST API or be handled by custom REST filters like `rest_{$this->post_type}_query`.
97
97
  ...restQueryArgs
98
98
  } = {},
99
- queryContext = [ { page: 1 } ],
100
99
  templateSlug,
101
100
  previewPostType,
102
101
  },
@@ -104,8 +103,6 @@ export default function PostTemplateEdit( {
104
103
  __unstableLayoutClassNames,
105
104
  } ) {
106
105
  const { type: layoutType, columnCount = 3 } = layout || {};
107
-
108
- const [ { page } ] = queryContext;
109
106
  const [ activeBlockContextId, setActiveBlockContextId ] = useState();
110
107
  const { posts, blocks } = useSelect(
111
108
  ( select ) => {
@@ -126,7 +123,7 @@ export default function PostTemplateEdit( {
126
123
  slug: templateSlug.replace( 'category-', '' ),
127
124
  } );
128
125
  const query = {
129
- offset: perPage ? perPage * ( page - 1 ) + offset : 0,
126
+ offset: perPage ? perPage + offset : 0,
130
127
  order,
131
128
  orderby: orderBy,
132
129
  };
@@ -194,7 +191,6 @@ export default function PostTemplateEdit( {
194
191
  },
195
192
  [
196
193
  perPage,
197
- page,
198
194
  offset,
199
195
  order,
200
196
  orderBy,
@@ -97,7 +97,6 @@ export default function PostTermsEdit( {
97
97
  <RichText
98
98
  allowedFormats={ ALLOWED_FORMATS }
99
99
  className="wp-block-post-terms__prefix"
100
- multiline={ false }
101
100
  aria-label={ __( 'Prefix' ) }
102
101
  placeholder={ __( 'Prefix' ) + ' ' }
103
102
  value={ prefix }
@@ -141,7 +140,6 @@ export default function PostTermsEdit( {
141
140
  <RichText
142
141
  allowedFormats={ ALLOWED_FORMATS }
143
142
  className="wp-block-post-terms__suffix"
144
- multiline={ false }
145
143
  aria-label={ __( 'Suffix' ) }
146
144
  placeholder={ ' ' + __( 'Suffix' ) }
147
145
  value={ suffix }
@@ -34,10 +34,7 @@ const transforms = {
34
34
  type: 'block',
35
35
  blocks: [ 'core/paragraph' ],
36
36
  transform: ( attributes ) =>
37
- createBlock( 'core/paragraph', {
38
- ...attributes,
39
- content: attributes.content.replace( /\n/g, '<br>' ),
40
- } ),
37
+ createBlock( 'core/paragraph', attributes ),
41
38
  },
42
39
  {
43
40
  type: 'block',
@@ -131,6 +131,7 @@ export default function QueryContent( {
131
131
  <InspectorControls group="advanced">
132
132
  <SelectControl
133
133
  __nextHasNoMarginBottom
134
+ __next40pxDefaultSize
134
135
  label={ __( 'HTML element' ) }
135
136
  options={ [
136
137
  { label: __( 'Default (<div>)' ), value: 'div' },
@@ -44,7 +44,11 @@ function render_block_core_query( $attributes, $content, $block ) {
44
44
  $block->block_type->supports['interactivity'] = true;
45
45
 
46
46
  // Add a div to announce messages using `aria-live`.
47
- $last_div_position = strripos( $content, '</div>' );
47
+ $html_tag = 'div';
48
+ if ( ! empty( $attributes['tagName'] ) ) {
49
+ $html_tag = esc_attr( $attributes['tagName'] );
50
+ }
51
+ $last_tag_position = strripos( $content, '</' . $html_tag . '>' );
48
52
  $content = substr_replace(
49
53
  $content,
50
54
  '<div
@@ -57,7 +61,7 @@ function render_block_core_query( $attributes, $content, $block ) {
57
61
  data-wp-class--start-animation="selectors.core.query.startAnimation"
58
62
  data-wp-class--finish-animation="selectors.core.query.finishAnimation"
59
63
  ></div>',
60
- $last_div_position,
64
+ $last_tag_position,
61
65
  0
62
66
  );
63
67
  }
@@ -54,6 +54,12 @@
54
54
  "background": true,
55
55
  "text": true
56
56
  }
57
+ },
58
+ "layout": {
59
+ "allowEditing": false
60
+ },
61
+ "spacing": {
62
+ "blockGap": true
57
63
  }
58
64
  },
59
65
  "styles": [
@@ -18,5 +18,9 @@
18
18
  font-size: 1.125em;
19
19
  text-align: right;
20
20
  }
21
+
22
+ }
23
+ > cite {
24
+ display: block;
21
25
  }
22
26
  }
@@ -1,7 +1,7 @@
1
1
  .wp-block-read-more {
2
2
  display: block;
3
3
  width: fit-content;
4
- &:not([style*="text-decoration"]) {
4
+ &:where(:not([style*="text-decoration"])) {
5
5
  text-decoration: none;
6
6
 
7
7
  &:focus,
@@ -95,6 +95,7 @@ export function TemplatePartAdvancedControls( {
95
95
  ) }
96
96
  <SelectControl
97
97
  __nextHasNoMarginBottom
98
+ __next40pxDefaultSize
98
99
  label={ __( 'HTML element' ) }
99
100
  options={ [
100
101
  {
@@ -4,7 +4,6 @@
4
4
  import { useSelect } from '@wordpress/data';
5
5
  import {
6
6
  BlockSettingsMenuControls,
7
- BlockTitle,
8
7
  useBlockProps,
9
8
  Warning,
10
9
  store as blockEditorStore,
@@ -14,7 +13,7 @@ import {
14
13
  import { Spinner, Modal, MenuItem } from '@wordpress/components';
15
14
  import { __, sprintf } from '@wordpress/i18n';
16
15
  import { store as coreStore } from '@wordpress/core-data';
17
- import { useState, createInterpolateElement } from '@wordpress/element';
16
+ import { useState } from '@wordpress/element';
18
17
 
19
18
  /**
20
19
  * Internal dependencies
@@ -35,7 +34,11 @@ export default function TemplatePartEdit( {
35
34
  setAttributes,
36
35
  clientId,
37
36
  } ) {
38
- const { slug, theme, tagName, layout = {} } = attributes;
37
+ const currentTheme = useSelect(
38
+ ( select ) => select( coreStore ).getCurrentTheme()?.stylesheet,
39
+ []
40
+ );
41
+ const { slug, theme = currentTheme, tagName, layout = {} } = attributes;
39
42
  const templatePartId = createTemplatePartId( theme, slug );
40
43
  const hasAlreadyRendered = useHasRecursion( templatePartId );
41
44
  const [ isTemplatePartSelectionOpen, setIsTemplatePartSelectionOpen ] =
@@ -174,17 +177,7 @@ export default function TemplatePartEdit( {
174
177
  }
175
178
  aria-haspopup="dialog"
176
179
  >
177
- { createInterpolateElement(
178
- __( 'Replace <BlockTitle />' ),
179
- {
180
- BlockTitle: (
181
- <BlockTitle
182
- clientId={ clientId }
183
- maximumLength={ 25 }
184
- />
185
- ),
186
- }
187
- ) }
180
+ { __( 'Replace' ) }
188
181
  </MenuItem>
189
182
  );
190
183
  } }
@@ -32,10 +32,11 @@ export const settings = {
32
32
  return;
33
33
  }
34
34
 
35
- const entity = select( coreDataStore ).getEntityRecord(
35
+ const { getCurrentTheme, getEntityRecord } = select( coreDataStore );
36
+ const entity = getEntityRecord(
36
37
  'postType',
37
38
  'wp_template_part',
38
- theme + '//' + slug
39
+ ( theme || getCurrentTheme()?.stylesheet ) + '//' + slug
39
40
  );
40
41
  if ( ! entity ) {
41
42
  return;
@@ -60,7 +61,7 @@ export const init = () => {
60
61
  const DISALLOWED_PARENTS = [ 'core/post-template', 'core/post-content' ];
61
62
  addFilter(
62
63
  'blockEditor.__unstableCanInsertBlockType',
63
- 'removeTemplatePartsFromPostTemplates',
64
+ 'core/block-library/removeTemplatePartsFromPostTemplates',
64
65
  (
65
66
  canInsert,
66
67
  blockType,
@@ -43,10 +43,10 @@ function render_block_core_template_part( $attributes ) {
43
43
  if ( $template_part_post ) {
44
44
  // A published post might already exist if this template part was customized elsewhere
45
45
  // or if it's part of a customized template.
46
- $content = $template_part_post->post_content;
47
- $area_terms = get_the_terms( $template_part_post, 'wp_template_part_area' );
48
- if ( ! is_wp_error( $area_terms ) && false !== $area_terms ) {
49
- $area = $area_terms[0]->name;
46
+ $block_template = _build_block_template_result_from_post( $template_part_post );
47
+ $content = $block_template->content;
48
+ if ( isset( $block_template->area ) ) {
49
+ $area = $block_template->area;
50
50
  }
51
51
  /**
52
52
  * Fires when a block template part is loaded from a template post stored in the database.
@@ -35,10 +35,12 @@ export function enhanceTemplatePartVariations( settings, name ) {
35
35
  // Find a matching variation from the created template part
36
36
  // by checking the entity's `area` property.
37
37
  if ( ! slug ) return false;
38
- const entity = select( coreDataStore ).getEntityRecord(
38
+ const { getCurrentTheme, getEntityRecord } =
39
+ select( coreDataStore );
40
+ const entity = getEntityRecord(
39
41
  'postType',
40
42
  'wp_template_part',
41
- `${ theme }//${ slug }`
43
+ `${ theme || getCurrentTheme()?.stylesheet }//${ slug }`
42
44
  );
43
45
 
44
46
  if ( entity?.slug ) {