@wordpress/block-library 7.14.2 → 7.14.4

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 (90) hide show
  1. package/build/comments-pagination-next/index.js +1 -1
  2. package/build/comments-pagination-numbers/index.js +1 -1
  3. package/build/comments-pagination-previous/index.js +1 -1
  4. package/build/gallery/deprecated.js +4 -4
  5. package/build/gallery/deprecated.js.map +1 -1
  6. package/build/navigation/edit/index.js +12 -12
  7. package/build/navigation/edit/index.js.map +1 -1
  8. package/build/navigation/menu-items-to-blocks.js +16 -6
  9. package/build/navigation/menu-items-to-blocks.js.map +1 -1
  10. package/build/post-content/edit.js +6 -1
  11. package/build/post-content/edit.js.map +1 -1
  12. package/build/post-featured-image/index.js +1 -1
  13. package/build/post-featured-image/overlay.js +2 -2
  14. package/build/post-featured-image/overlay.js.map +1 -1
  15. package/build/post-template/edit.js +13 -28
  16. package/build/post-template/edit.js.map +1 -1
  17. package/build/query/edit/inspector-controls/index.js +1 -1
  18. package/build/query/edit/inspector-controls/index.js.map +1 -1
  19. package/build/query/utils.js +1 -1
  20. package/build/query/utils.js.map +1 -1
  21. package/build/quote/index.js +0 -1
  22. package/build/quote/index.js.map +1 -1
  23. package/build/quote/transforms.js +2 -2
  24. package/build/quote/transforms.js.map +1 -1
  25. package/build/template-part/edit/index.js +2 -2
  26. package/build/template-part/edit/index.js.map +1 -1
  27. package/build/template-part/index.js +2 -2
  28. package/build/template-part/index.js.map +1 -1
  29. package/build-module/comments-pagination-next/index.js +1 -1
  30. package/build-module/comments-pagination-numbers/index.js +1 -1
  31. package/build-module/comments-pagination-previous/index.js +1 -1
  32. package/build-module/gallery/deprecated.js +4 -4
  33. package/build-module/gallery/deprecated.js.map +1 -1
  34. package/build-module/navigation/edit/index.js +12 -12
  35. package/build-module/navigation/edit/index.js.map +1 -1
  36. package/build-module/navigation/menu-items-to-blocks.js +16 -6
  37. package/build-module/navigation/menu-items-to-blocks.js.map +1 -1
  38. package/build-module/post-content/edit.js +6 -1
  39. package/build-module/post-content/edit.js.map +1 -1
  40. package/build-module/post-featured-image/index.js +1 -1
  41. package/build-module/post-featured-image/overlay.js +2 -2
  42. package/build-module/post-featured-image/overlay.js.map +1 -1
  43. package/build-module/post-template/edit.js +14 -29
  44. package/build-module/post-template/edit.js.map +1 -1
  45. package/build-module/query/edit/inspector-controls/index.js +1 -1
  46. package/build-module/query/edit/inspector-controls/index.js.map +1 -1
  47. package/build-module/query/utils.js +1 -1
  48. package/build-module/query/utils.js.map +1 -1
  49. package/build-module/quote/index.js +0 -1
  50. package/build-module/quote/index.js.map +1 -1
  51. package/build-module/quote/transforms.js +2 -2
  52. package/build-module/quote/transforms.js.map +1 -1
  53. package/build-module/template-part/edit/index.js +3 -3
  54. package/build-module/template-part/edit/index.js.map +1 -1
  55. package/build-module/template-part/index.js +2 -2
  56. package/build-module/template-part/index.js.map +1 -1
  57. package/build-style/classic-rtl.css +85 -0
  58. package/build-style/classic.css +85 -0
  59. package/build-style/code/style-rtl.css +3 -0
  60. package/build-style/code/style.css +3 -0
  61. package/build-style/editor-rtl.css +39 -29
  62. package/build-style/editor.css +39 -29
  63. package/build-style/post-featured-image/editor-rtl.css +39 -29
  64. package/build-style/post-featured-image/editor.css +39 -29
  65. package/build-style/style-rtl.css +3 -0
  66. package/build-style/style.css +3 -0
  67. package/package.json +12 -12
  68. package/src/classic.scss +15 -0
  69. package/src/code/style.scss +12 -7
  70. package/src/comment-template/index.php +18 -8
  71. package/src/comments-pagination-next/block.json +1 -1
  72. package/src/comments-pagination-numbers/block.json +1 -1
  73. package/src/comments-pagination-previous/block.json +1 -1
  74. package/src/gallery/deprecated.js +4 -4
  75. package/src/navigation/edit/index.js +12 -10
  76. package/src/navigation/menu-items-to-blocks.js +39 -22
  77. package/src/navigation/test/menu-items-to-blocks.js +6 -0
  78. package/src/navigation-submenu/index.php +10 -1
  79. package/src/post-content/edit.js +3 -1
  80. package/src/post-featured-image/block.json +1 -1
  81. package/src/post-featured-image/editor.scss +79 -72
  82. package/src/post-featured-image/index.php +18 -24
  83. package/src/post-featured-image/overlay.js +17 -14
  84. package/src/post-template/edit.js +14 -23
  85. package/src/query/edit/inspector-controls/index.js +1 -4
  86. package/src/query/utils.js +1 -1
  87. package/src/quote/block.json +0 -1
  88. package/src/quote/transforms.js +1 -1
  89. package/src/template-part/edit/index.js +60 -58
  90. package/src/template-part/index.js +2 -2
@@ -83,16 +83,25 @@ function get_block_core_post_featured_image_overlay_element_markup( $attributes
83
83
  $has_custom_gradient = isset( $attributes['customGradient'] ) && $attributes['customGradient'];
84
84
  $has_solid_overlay = isset( $attributes['overlayColor'] ) && $attributes['overlayColor'];
85
85
  $has_custom_overlay = isset( $attributes['customOverlayColor'] ) && $attributes['customOverlayColor'];
86
- $class_names = array(
87
- 'wp-block-post-featured-image__overlay',
88
- );
89
- $styles_properties = array();
86
+ $class_names = array( 'wp-block-post-featured-image__overlay' );
87
+ $styles = array();
90
88
 
91
89
  if ( ! $has_dim_background ) {
92
90
  return '';
93
91
  }
94
92
 
95
- // Generate required classes for the element.
93
+ // Apply border classes and styles.
94
+ $border_attributes = get_block_core_post_featured_image_border_attributes( $attributes );
95
+
96
+ if ( ! empty( $border_attributes['class'] ) ) {
97
+ $class_names[] = $border_attributes['class'];
98
+ }
99
+
100
+ if ( ! empty( $border_attributes['style'] ) ) {
101
+ $styles[] = $border_attributes['style'];
102
+ }
103
+
104
+ // Apply overlay and gradient classes.
96
105
  if ( $has_dim_background ) {
97
106
  $class_names[] = 'has-background-dim';
98
107
  $class_names[] = "has-background-dim-{$attributes['dimRatio']}";
@@ -110,35 +119,20 @@ function get_block_core_post_featured_image_overlay_element_markup( $attributes
110
119
  $class_names[] = "has-{$attributes['gradient']}-gradient-background";
111
120
  }
112
121
 
113
- // Generate required CSS properties and their values.
114
- if ( ! empty( $attributes['style']['border']['radius'] ) ) {
115
- $styles_properties['border-radius'] = $attributes['style']['border']['radius'];
116
- }
117
-
118
- if ( ! empty( $attributes['style']['border']['width'] ) ) {
119
- $styles_properties['border-width'] = $attributes['style']['border']['width'];
120
- }
121
-
122
+ // Apply background styles.
122
123
  if ( $has_custom_gradient ) {
123
- $styles_properties['background-image'] = $attributes['customGradient'];
124
+ $styles[] = sprintf( 'background-image: %s;', $attributes['customGradient'] );
124
125
  }
125
126
 
126
127
  if ( $has_custom_overlay ) {
127
- $styles_properties['background-color'] = $attributes['customOverlayColor'];
128
- }
129
-
130
- $styles = '';
131
-
132
- foreach ( $styles_properties as $style_attribute => $style_attribute_value ) {
133
- $styles .= "{$style_attribute}: $style_attribute_value; ";
128
+ $styles[] = sprintf( 'background-color: %s;', $attributes['customOverlayColor'] );
134
129
  }
135
130
 
136
131
  return sprintf(
137
132
  '<span class="%s" style="%s" aria-hidden="true"></span>',
138
133
  esc_attr( implode( ' ', $class_names ) ),
139
- esc_attr( trim( $styles ) )
134
+ esc_attr( safecss_filter_attr( implode( ' ', $styles ) ) )
140
135
  );
141
-
142
136
  }
143
137
 
144
138
  /**
@@ -47,20 +47,23 @@ const Overlay = ( {
47
47
 
48
48
  return (
49
49
  <>
50
- <span
51
- aria-hidden="true"
52
- className={ classnames(
53
- 'wp-block-post-featured-image__overlay',
54
- dimRatioToClass( dimRatio ),
55
- {
56
- [ overlayColor.class ]: overlayColor.class,
57
- 'has-background-dim': dimRatio !== undefined,
58
- 'has-background-gradient': gradientValue,
59
- [ gradientClass ]: gradientClass,
60
- }
61
- ) }
62
- style={ overlayStyles }
63
- />
50
+ { !! dimRatio && (
51
+ <span
52
+ aria-hidden="true"
53
+ className={ classnames(
54
+ 'wp-block-post-featured-image__overlay',
55
+ dimRatioToClass( dimRatio ),
56
+ {
57
+ [ overlayColor.class ]: overlayColor.class,
58
+ 'has-background-dim': dimRatio !== undefined,
59
+ 'has-background-gradient': gradientValue,
60
+ [ gradientClass ]: gradientClass,
61
+ },
62
+ borderProps.className
63
+ ) }
64
+ style={ overlayStyles }
65
+ />
66
+ ) }
64
67
  <InspectorControls __experimentalGroup="color">
65
68
  <ColorGradientSettingsDropdown
66
69
  __experimentalHasMultipleOrigins
@@ -17,7 +17,7 @@ import {
17
17
  store as blockEditorStore,
18
18
  } from '@wordpress/block-editor';
19
19
  import { Spinner } from '@wordpress/components';
20
- import { store as coreStore, useEntityRecords } from '@wordpress/core-data';
20
+ import { store as coreStore } from '@wordpress/core-data';
21
21
 
22
22
  const TEMPLATE = [
23
23
  [ 'core/post-title' ],
@@ -101,19 +101,6 @@ export default function PostTemplateEdit( {
101
101
  } ) {
102
102
  const [ { page } ] = queryContext;
103
103
  const [ activeBlockContextId, setActiveBlockContextId ] = useState();
104
-
105
- let categorySlug = null;
106
- if ( templateSlug?.startsWith( 'category-' ) ) {
107
- categorySlug = templateSlug.replace( 'category-', '' );
108
- }
109
- const { records: categories, hasResolved: hasResolvedCategories } =
110
- useEntityRecords( 'taxonomy', 'category', {
111
- context: 'view',
112
- per_page: -1,
113
- _fields: [ 'id' ],
114
- slug: categorySlug,
115
- } );
116
-
117
104
  const { posts, blocks } = useSelect(
118
105
  ( select ) => {
119
106
  const { getEntityRecords, getTaxonomies } = select( coreStore );
@@ -123,12 +110,22 @@ export default function PostTemplateEdit( {
123
110
  per_page: -1,
124
111
  context: 'view',
125
112
  } );
113
+ const templateCategory =
114
+ inherit &&
115
+ templateSlug?.startsWith( 'category-' ) &&
116
+ getEntityRecords( 'taxonomy', 'category', {
117
+ context: 'view',
118
+ per_page: 1,
119
+ _fields: [ 'id' ],
120
+ slug: templateSlug.replace( 'category-', '' ),
121
+ } );
126
122
  const query = {
127
123
  offset: perPage ? perPage * ( page - 1 ) + offset : 0,
128
124
  order,
129
125
  orderby: orderBy,
130
126
  };
131
- if ( taxQuery ) {
127
+ // There is no need to build the taxQuery if we inherit.
128
+ if ( taxQuery && ! inherit ) {
132
129
  // We have to build the tax query for the REST API and use as
133
130
  // keys the taxonomies `rest_base` with the `term ids` as values.
134
131
  const builtTaxQuery = Object.entries( taxQuery ).reduce(
@@ -174,11 +171,8 @@ export default function PostTemplateEdit( {
174
171
  if ( templateSlug?.startsWith( 'archive-' ) ) {
175
172
  query.postType = templateSlug.replace( 'archive-', '' );
176
173
  postType = query.postType;
177
- } else if ( !! categorySlug && hasResolvedCategories ) {
178
- query.taxQuery = {
179
- category: categories.map( ( { id } ) => id ),
180
- };
181
- taxQuery = query.taxQuery;
174
+ } else if ( templateCategory ) {
175
+ query.categories = templateCategory[ 0 ]?.id;
182
176
  }
183
177
  }
184
178
  // When we preview Query Loop blocks we should prefer the current
@@ -210,9 +204,6 @@ export default function PostTemplateEdit( {
210
204
  parents,
211
205
  restQueryArgs,
212
206
  previewPostType,
213
- categories,
214
- categorySlug,
215
- hasResolvedCategories,
216
207
  ]
217
208
  );
218
209
  const blockContexts = useMemo(
@@ -241,10 +241,7 @@ export default function QueryInspectorControls( {
241
241
  </ToolsPanelItem>
242
242
  ) }
243
243
  { isPostTypeHierarchical &&
244
- ! isControlAllowed(
245
- allowedControls,
246
- 'parents'
247
- ) && (
244
+ isControlAllowed( allowedControls, 'parents' ) && (
248
245
  <ToolsPanelItem
249
246
  hasValue={ () => !! parents?.length }
250
247
  label={ __( 'Parents' ) }
@@ -162,7 +162,7 @@ export function useAllowedControls( attributes ) {
162
162
  select( blocksStore ).getActiveBlockVariation(
163
163
  queryLoopName,
164
164
  attributes
165
- )?.allowControls,
165
+ )?.allowedControls,
166
166
 
167
167
  [ attributes ]
168
168
  );
@@ -29,7 +29,6 @@
29
29
  },
30
30
  "supports": {
31
31
  "anchor": true,
32
- "__experimentalSlashInserter": true,
33
32
  "__experimentalOnEnter": true,
34
33
  "typography": {
35
34
  "fontSize": true,
@@ -17,7 +17,7 @@ const transforms = {
17
17
  fontSize,
18
18
  style,
19
19
  },
20
- createBlock( 'core/paragraph', { content: value } )
20
+ [ createBlock( 'core/paragraph', { content: value } ) ]
21
21
  );
22
22
  },
23
23
  },
@@ -133,64 +133,66 @@ export default function TemplatePartEdit( {
133
133
  }
134
134
 
135
135
  return (
136
- <RecursionProvider uniqueId={ templatePartId }>
137
- <TemplatePartAdvancedControls
138
- tagName={ tagName }
139
- setAttributes={ setAttributes }
140
- isEntityAvailable={ isEntityAvailable }
141
- templatePartId={ templatePartId }
142
- defaultWrapper={ areaObject.tagName }
143
- />
144
- { isPlaceholder && (
145
- <TagName { ...blockProps }>
146
- <TemplatePartPlaceholder
147
- area={ attributes.area }
148
- templatePartId={ templatePartId }
149
- clientId={ clientId }
150
- setAttributes={ setAttributes }
151
- onOpenSelectionModal={ () =>
152
- setIsTemplatePartSelectionOpen( true )
153
- }
154
- />
155
- </TagName>
156
- ) }
157
- { canReplace && (
158
- <BlockSettingsMenuControls>
159
- { () => (
160
- <MenuItem
161
- onClick={ () => {
162
- setIsTemplatePartSelectionOpen( true );
163
- } }
164
- >
165
- { createInterpolateElement(
166
- __( 'Replace <BlockTitle />' ),
167
- {
168
- BlockTitle: (
169
- <BlockTitle
170
- clientId={ clientId }
171
- maximumLength={ 25 }
172
- />
173
- ),
174
- }
175
- ) }
176
- </MenuItem>
177
- ) }
178
- </BlockSettingsMenuControls>
179
- ) }
180
- { isEntityAvailable && (
181
- <TemplatePartInnerBlocks
182
- tagName={ TagName }
183
- blockProps={ blockProps }
184
- postId={ templatePartId }
185
- hasInnerBlocks={ innerBlocks.length > 0 }
186
- layout={ layout }
136
+ <>
137
+ <RecursionProvider uniqueId={ templatePartId }>
138
+ <TemplatePartAdvancedControls
139
+ tagName={ tagName }
140
+ setAttributes={ setAttributes }
141
+ isEntityAvailable={ isEntityAvailable }
142
+ templatePartId={ templatePartId }
143
+ defaultWrapper={ areaObject.tagName }
187
144
  />
188
- ) }
189
- { ! isPlaceholder && ! isResolved && (
190
- <TagName { ...blockProps }>
191
- <Spinner />
192
- </TagName>
193
- ) }
145
+ { isPlaceholder && (
146
+ <TagName { ...blockProps }>
147
+ <TemplatePartPlaceholder
148
+ area={ attributes.area }
149
+ templatePartId={ templatePartId }
150
+ clientId={ clientId }
151
+ setAttributes={ setAttributes }
152
+ onOpenSelectionModal={ () =>
153
+ setIsTemplatePartSelectionOpen( true )
154
+ }
155
+ />
156
+ </TagName>
157
+ ) }
158
+ { canReplace && (
159
+ <BlockSettingsMenuControls>
160
+ { () => (
161
+ <MenuItem
162
+ onClick={ () => {
163
+ setIsTemplatePartSelectionOpen( true );
164
+ } }
165
+ >
166
+ { createInterpolateElement(
167
+ __( 'Replace <BlockTitle />' ),
168
+ {
169
+ BlockTitle: (
170
+ <BlockTitle
171
+ clientId={ clientId }
172
+ maximumLength={ 25 }
173
+ />
174
+ ),
175
+ }
176
+ ) }
177
+ </MenuItem>
178
+ ) }
179
+ </BlockSettingsMenuControls>
180
+ ) }
181
+ { isEntityAvailable && (
182
+ <TemplatePartInnerBlocks
183
+ tagName={ TagName }
184
+ blockProps={ blockProps }
185
+ postId={ templatePartId }
186
+ hasInnerBlocks={ innerBlocks.length > 0 }
187
+ layout={ layout }
188
+ />
189
+ ) }
190
+ { ! isPlaceholder && ! isResolved && (
191
+ <TagName { ...blockProps }>
192
+ <Spinner />
193
+ </TagName>
194
+ ) }
195
+ </RecursionProvider>
194
196
  { isTemplatePartSelectionOpen && (
195
197
  <Modal
196
198
  overlayClassName="block-editor-template-part__selection-modal"
@@ -215,6 +217,6 @@ export default function TemplatePartEdit( {
215
217
  />
216
218
  </Modal>
217
219
  ) }
218
- </RecursionProvider>
220
+ </>
219
221
  );
220
222
  }
@@ -62,13 +62,13 @@ export const init = () => {
62
62
  'blockEditor.__unstableCanInsertBlockType',
63
63
  'removeTemplatePartsFromPostTemplates',
64
64
  (
65
- can,
65
+ canInsert,
66
66
  blockType,
67
67
  rootClientId,
68
68
  { getBlock, getBlockParentsByBlockName }
69
69
  ) => {
70
70
  if ( blockType.name !== 'core/template-part' ) {
71
- return can;
71
+ return canInsert;
72
72
  }
73
73
 
74
74
  for ( const disallowedParentType of DISALLOWED_PARENTS ) {