@wordpress/block-library 9.33.7 → 9.33.9

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 (72) hide show
  1. package/build/accordion/view.js +46 -4
  2. package/build/accordion/view.js.map +2 -2
  3. package/build/accordion-heading/block.json +1 -1
  4. package/build/accordion-heading/deprecated.js +1 -1
  5. package/build/accordion-heading/deprecated.js.map +2 -2
  6. package/build/accordion-panel/block.json +1 -1
  7. package/build/freeform/block.json +1 -1
  8. package/build/math/edit.js +4 -1
  9. package/build/math/edit.js.map +2 -2
  10. package/build/missing/block.json +1 -1
  11. package/build/navigation-link/edit.js +7 -1
  12. package/build/navigation-link/edit.js.map +2 -2
  13. package/build/navigation-link/shared/controls.js +15 -19
  14. package/build/navigation-link/shared/controls.js.map +2 -2
  15. package/build/navigation-link/shared/index.js +4 -0
  16. package/build/navigation-link/shared/index.js.map +2 -2
  17. package/build/navigation-link/shared/use-entity-binding.js +3 -2
  18. package/build/navigation-link/shared/use-entity-binding.js.map +2 -2
  19. package/build/pattern/block.json +1 -1
  20. package/build/social-links/edit.js +1 -1
  21. package/build/social-links/edit.js.map +1 -1
  22. package/build-module/accordion/view.js +46 -4
  23. package/build-module/accordion/view.js.map +2 -2
  24. package/build-module/accordion-heading/block.json +1 -1
  25. package/build-module/accordion-heading/deprecated.js +1 -1
  26. package/build-module/accordion-heading/deprecated.js.map +2 -2
  27. package/build-module/accordion-panel/block.json +1 -1
  28. package/build-module/freeform/block.json +1 -1
  29. package/build-module/math/edit.js +4 -1
  30. package/build-module/math/edit.js.map +2 -2
  31. package/build-module/missing/block.json +1 -1
  32. package/build-module/navigation-link/edit.js +21 -5
  33. package/build-module/navigation-link/edit.js.map +2 -2
  34. package/build-module/navigation-link/shared/controls.js +12 -18
  35. package/build-module/navigation-link/shared/controls.js.map +2 -2
  36. package/build-module/navigation-link/shared/index.js +3 -1
  37. package/build-module/navigation-link/shared/index.js.map +2 -2
  38. package/build-module/navigation-link/shared/use-entity-binding.js +3 -2
  39. package/build-module/navigation-link/shared/use-entity-binding.js.map +2 -2
  40. package/build-module/pattern/block.json +1 -1
  41. package/build-module/social-links/edit.js +1 -1
  42. package/build-module/social-links/edit.js.map +1 -1
  43. package/build-style/accordion/style-rtl.css +3 -0
  44. package/build-style/accordion/style.css +3 -0
  45. package/build-style/accordion-heading/style-rtl.css +1 -2
  46. package/build-style/accordion-heading/style.css +1 -2
  47. package/build-style/accordion-item/style-rtl.css +0 -7
  48. package/build-style/accordion-item/style.css +0 -7
  49. package/build-style/accordion-panel/style-rtl.css +1 -4
  50. package/build-style/accordion-panel/style.css +1 -4
  51. package/build-style/style-rtl.css +5 -12
  52. package/build-style/style.css +5 -12
  53. package/package.json +8 -8
  54. package/src/accordion/style.scss +4 -0
  55. package/src/accordion/view.js +60 -3
  56. package/src/accordion-heading/block.json +1 -1
  57. package/src/accordion-heading/deprecated.js +1 -1
  58. package/src/accordion-heading/style.scss +1 -9
  59. package/src/accordion-item/index.php +1 -0
  60. package/src/accordion-item/style.scss +2 -9
  61. package/src/accordion-panel/block.json +1 -1
  62. package/src/accordion-panel/style.scss +1 -5
  63. package/src/freeform/block.json +1 -1
  64. package/src/math/edit.js +4 -1
  65. package/src/missing/block.json +1 -1
  66. package/src/navigation-link/edit.js +28 -5
  67. package/src/navigation-link/shared/controls.js +13 -17
  68. package/src/navigation-link/shared/index.js +1 -1
  69. package/src/navigation-link/shared/use-entity-binding.js +5 -2
  70. package/src/pattern/block.json +1 -1
  71. package/src/social-links/edit.js +1 -1
  72. package/src/style.scss +1 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wordpress/block-library",
3
- "version": "9.33.7",
3
+ "version": "9.33.9",
4
4
  "description": "Block library for the WordPress editor.",
5
5
  "author": "The WordPress Contributors",
6
6
  "license": "GPL-2.0-or-later",
@@ -86,11 +86,11 @@
86
86
  "@wordpress/autop": "^4.33.1",
87
87
  "@wordpress/base-styles": "^6.9.1",
88
88
  "@wordpress/blob": "^4.33.1",
89
- "@wordpress/block-editor": "^15.6.6",
89
+ "@wordpress/block-editor": "^15.6.8",
90
90
  "@wordpress/blocks": "^15.6.2",
91
91
  "@wordpress/components": "^30.6.4",
92
92
  "@wordpress/compose": "^7.33.1",
93
- "@wordpress/core-data": "^7.33.6",
93
+ "@wordpress/core-data": "^7.33.8",
94
94
  "@wordpress/data": "^10.33.1",
95
95
  "@wordpress/date": "^5.33.1",
96
96
  "@wordpress/deprecated": "^4.33.1",
@@ -101,16 +101,16 @@
101
101
  "@wordpress/html-entities": "^4.33.1",
102
102
  "@wordpress/i18n": "^6.6.1",
103
103
  "@wordpress/icons": "^11.0.1",
104
- "@wordpress/interactivity": "^6.33.1",
105
- "@wordpress/interactivity-router": "^2.33.1",
104
+ "@wordpress/interactivity": "^6.33.2",
105
+ "@wordpress/interactivity-router": "^2.33.2",
106
106
  "@wordpress/keyboard-shortcuts": "^5.33.1",
107
107
  "@wordpress/keycodes": "^4.33.1",
108
108
  "@wordpress/latex-to-mathml": "^1.1.2",
109
109
  "@wordpress/notices": "^5.33.1",
110
- "@wordpress/patterns": "^2.33.6",
110
+ "@wordpress/patterns": "^2.33.8",
111
111
  "@wordpress/primitives": "^4.33.1",
112
112
  "@wordpress/private-apis": "^1.33.1",
113
- "@wordpress/reusable-blocks": "^5.33.6",
113
+ "@wordpress/reusable-blocks": "^5.33.8",
114
114
  "@wordpress/rich-text": "^7.33.2",
115
115
  "@wordpress/server-side-render": "^6.9.4",
116
116
  "@wordpress/url": "^4.33.1",
@@ -133,5 +133,5 @@
133
133
  "publishConfig": {
134
134
  "access": "public"
135
135
  },
136
- "gitHead": "e821b2ec0a90d60aa7cafc248ba049f13b4265b7"
136
+ "gitHead": "52db1c3ee45bd12b1e3dc65490edc6db5b9ab78f"
137
137
  }
@@ -0,0 +1,4 @@
1
+ .wp-block-accordion {
2
+ // This block has customizable padding, border-box makes that more predictable.
3
+ box-sizing: border-box;
4
+ }
@@ -3,7 +3,11 @@
3
3
  */
4
4
  import { store, getContext, withSyncEvent } from '@wordpress/interactivity';
5
5
 
6
- store(
6
+ // Whether the hash has been handled for the current page load.
7
+ // This is used to prevent the hash from being handled multiple times.
8
+ let hashHandled = false;
9
+
10
+ const { actions } = store(
7
11
  'core/accordion',
8
12
  {
9
13
  state: {
@@ -75,15 +79,68 @@ store(
75
79
  nextButton.focus();
76
80
  }
77
81
  } ),
82
+ openPanelByHash: () => {
83
+ if ( hashHandled || ! window.location?.hash?.length ) {
84
+ return;
85
+ }
86
+
87
+ const context = getContext();
88
+ const { id, accordionItems, autoclose } = context;
89
+ const hash = decodeURIComponent(
90
+ window.location.hash.slice( 1 )
91
+ );
92
+ const targetElement = window.document.getElementById( hash );
93
+
94
+ if ( ! targetElement ) {
95
+ return;
96
+ }
97
+
98
+ const panelElement = window.document.querySelector(
99
+ '.wp-block-accordion-panel[aria-labelledby="' + id + '"]'
100
+ );
101
+
102
+ if (
103
+ ! panelElement ||
104
+ ! panelElement.contains( targetElement )
105
+ ) {
106
+ return;
107
+ }
108
+
109
+ hashHandled = true;
110
+
111
+ if ( autoclose ) {
112
+ accordionItems.forEach( ( item ) => {
113
+ item.isOpen = item.id === id;
114
+ } );
115
+ } else {
116
+ const targetItem = accordionItems.find(
117
+ ( item ) => item.id === id
118
+ );
119
+
120
+ if ( targetItem ) {
121
+ targetItem.isOpen = true;
122
+ }
123
+ }
124
+
125
+ // Wait for the panel to be opened before scrolling to it.
126
+ window.setTimeout( () => {
127
+ targetElement.scrollIntoView();
128
+ }, 0 );
129
+ },
78
130
  },
79
131
  callbacks: {
80
132
  initAccordionItems: () => {
81
133
  const context = getContext();
82
- const { id, openByDefault } = context;
83
- context.accordionItems.push( {
134
+ const { id, openByDefault, accordionItems } = context;
135
+ accordionItems.push( {
84
136
  id,
85
137
  isOpen: openByDefault,
86
138
  } );
139
+ actions.openPanelByHash();
140
+ },
141
+ hashChange: () => {
142
+ hashHandled = false;
143
+ actions.openPanelByHash();
87
144
  },
88
145
  },
89
146
  },
@@ -57,7 +57,7 @@
57
57
  }
58
58
  },
59
59
  "shadow": true,
60
- "blockVisibility": false,
60
+ "visibility": false,
61
61
  "lock": false
62
62
  },
63
63
  "selectors": {
@@ -74,7 +74,7 @@ const v1 = {
74
74
  },
75
75
  },
76
76
  shadow: true,
77
- blockVisibility: false,
77
+ visibility: false,
78
78
  },
79
79
  save( { attributes } ) {
80
80
  const { level, title, iconPosition, showIcon } = attributes;
@@ -1,12 +1,4 @@
1
- // In many classic themes, selectors like `.entry-content h1` are used,
2
- // potentially applying relatively high specificity (such as `0-1-1`) to
3
- // heading elements. To properly override those styles, use a selector
4
- // with a specificity of `0-2-0`.
5
- .wp-block-accordion-heading.wp-block-accordion-heading {
6
- // Some themes may have an explicit width. Since it's unpredictable
7
- // what CSS specificity should be used to override them, ensure 100%
8
- // width using min-width instead.
9
- min-width: 100%;
1
+ .wp-block-accordion-heading {
10
2
  // Some classic themes apply default margins to heading elements,
11
3
  // so those styles need to be reset.
12
4
  margin: 0;
@@ -36,6 +36,7 @@ function block_core_accordion_item_render( $attributes, $content ) {
36
36
  $p->set_attribute( 'data-wp-context', '{ "id": "' . $unique_id . '", "openByDefault": ' . $open_by_default . ' }' );
37
37
  $p->set_attribute( 'data-wp-class--is-open', 'state.isOpen' );
38
38
  $p->set_attribute( 'data-wp-init', 'callbacks.initAccordionItems' );
39
+ $p->set_attribute( 'data-wp-on-window--hashchange', 'callbacks.hashChange' );
39
40
 
40
41
  if ( $p->next_tag( array( 'class_name' => 'wp-block-accordion-heading__toggle' ) ) ) {
41
42
  $p->set_attribute( 'data-wp-on--click', 'actions.toggle' );
@@ -1,13 +1,6 @@
1
1
  .wp-block-accordion-item {
2
- display: grid;
3
- grid-template-rows: max-content 0fr;
4
-
5
- &.is-open {
6
- grid-template-rows: max-content 1fr;
7
-
8
- > .wp-block-accordion-heading .wp-block-accordion-heading__toggle-icon {
9
- transform: rotate(45deg);
10
- }
2
+ &.is-open > .wp-block-accordion-heading .wp-block-accordion-heading__toggle-icon {
3
+ transform: rotate(45deg);
11
4
  }
12
5
 
13
6
  /* Add transitions only for users who do not prefer reduced motion */
@@ -50,7 +50,7 @@
50
50
  "layout": {
51
51
  "allowEditing": false
52
52
  },
53
- "blockVisibility": false,
53
+ "visibility": false,
54
54
  "contentRole": true,
55
55
  "allowedBlocks": true,
56
56
  "lock": false
@@ -1,8 +1,4 @@
1
- // Some classic themes may use selectors like `.wp-block .wp-block`
2
- // and apply some kind of width to the blocks. To properly override
3
- // those styles, use a selector with a specificity of `0-2-0`.
4
- .wp-block-accordion-panel.wp-block-accordion-panel {
5
- min-width: 100%;
1
+ .wp-block-accordion-panel {
6
2
 
7
3
  // Prevent blockGap from Accordion Content block from adding extra margin between accordions.
8
4
  &[inert],
@@ -19,7 +19,7 @@
19
19
  "lock": false,
20
20
  "reusable": false,
21
21
  "renaming": false,
22
- "blockVisibility": false
22
+ "visibility": false
23
23
  },
24
24
  "editorStyle": "wp-block-freeform-editor"
25
25
  }
package/src/math/edit.js CHANGED
@@ -14,6 +14,7 @@ import {
14
14
  } from '@wordpress/components';
15
15
  import { useState, useEffect, useRef } from '@wordpress/element';
16
16
  import { useDispatch } from '@wordpress/data';
17
+ import { speak } from '@wordpress/a11y';
17
18
 
18
19
  /**
19
20
  * Internal dependencies
@@ -72,7 +73,8 @@ export default function MathEdit( { attributes, setAttributes, isSelected } ) {
72
73
  placement="bottom-start"
73
74
  offset={ 8 }
74
75
  anchor={ blockRef }
75
- focusOnMount="firstContentElement"
76
+ focusOnMount={ false }
77
+ __unstableSlotName="__unstable-block-tools-after"
76
78
  >
77
79
  <div style={ { padding: '4px', minWidth: '300px' } }>
78
80
  <VStack spacing={ 1 }>
@@ -96,6 +98,7 @@ export default function MathEdit( { attributes, setAttributes, isSelected } ) {
96
98
  setError( null );
97
99
  } catch ( err ) {
98
100
  setError( err.message );
101
+ speak( err.message );
99
102
  }
100
103
  setAttributes( {
101
104
  mathML: newMathML,
@@ -26,7 +26,7 @@
26
26
  "lock": false,
27
27
  "reusable": false,
28
28
  "renaming": false,
29
- "blockVisibility": false,
29
+ "visibility": false,
30
30
  "interactivity": {
31
31
  "clientNavigation": true
32
32
  }
@@ -8,9 +8,13 @@ import clsx from 'clsx';
8
8
  */
9
9
  import { createBlock } from '@wordpress/blocks';
10
10
  import { useSelect, useDispatch } from '@wordpress/data';
11
- import { ToolbarButton, ToolbarGroup } from '@wordpress/components';
11
+ import {
12
+ ToolbarButton,
13
+ ToolbarGroup,
14
+ VisuallyHidden,
15
+ } from '@wordpress/components';
12
16
  import { displayShortcut, isKeyboardEvent } from '@wordpress/keycodes';
13
- import { __ } from '@wordpress/i18n';
17
+ import { __, sprintf } from '@wordpress/i18n';
14
18
  import {
15
19
  BlockControls,
16
20
  InspectorControls,
@@ -26,13 +30,19 @@ import { useState, useEffect, useRef, useCallback } from '@wordpress/element';
26
30
  import { decodeEntities } from '@wordpress/html-entities';
27
31
  import { link as linkIcon, addSubmenu } from '@wordpress/icons';
28
32
  import { store as coreStore } from '@wordpress/core-data';
29
- import { useMergeRefs, usePrevious } from '@wordpress/compose';
33
+ import { useMergeRefs, usePrevious, useInstanceId } from '@wordpress/compose';
30
34
 
31
35
  /**
32
36
  * Internal dependencies
33
37
  */
34
38
  import { getColors } from '../navigation/edit/utils';
35
- import { Controls, LinkUI, updateAttributes, useEntityBinding } from './shared';
39
+ import {
40
+ Controls,
41
+ LinkUI,
42
+ updateAttributes,
43
+ useEntityBinding,
44
+ MissingEntityHelpText,
45
+ } from './shared';
36
46
 
37
47
  const DEFAULT_BLOCK = { name: 'core/navigation-link' };
38
48
  const NESTING_BLOCK_NAMES = [
@@ -204,7 +214,7 @@ export default function NavigationLinkEdit( {
204
214
  const ref = useRef();
205
215
  const linkUIref = useRef();
206
216
  const prevUrl = usePrevious( url );
207
- const isNewLink = useRef( ! url );
217
+ const isNewLink = useRef( ! url && ! metadata?.bindings?.url );
208
218
 
209
219
  const {
210
220
  isAtMaxNesting,
@@ -394,6 +404,12 @@ export default function NavigationLinkEdit( {
394
404
  }
395
405
  }
396
406
 
407
+ const instanceId = useInstanceId( NavigationLinkEdit );
408
+ const hasMissingEntity = hasUrlBinding && ! isBoundEntityAvailable;
409
+ const missingEntityDescriptionId = hasMissingEntity
410
+ ? sprintf( 'navigation-link-edit-%d-desc', instanceId )
411
+ : undefined;
412
+
397
413
  const blockProps = useBlockProps( {
398
414
  ref: useMergeRefs( [ setPopoverAnchor, listItemRef ] ),
399
415
  className: clsx( 'wp-block-navigation-item', {
@@ -407,6 +423,8 @@ export default function NavigationLinkEdit( {
407
423
  [ getColorClassName( 'background-color', backgroundColor ) ]:
408
424
  !! backgroundColor,
409
425
  } ),
426
+ 'aria-describedby': missingEntityDescriptionId,
427
+ 'aria-invalid': hasMissingEntity,
410
428
  style: {
411
429
  color: ! textColor && customTextColor,
412
430
  backgroundColor: ! backgroundColor && customBackgroundColor,
@@ -482,6 +500,11 @@ export default function NavigationLinkEdit( {
482
500
  />
483
501
  </InspectorControls>
484
502
  <div { ...blockProps }>
503
+ { hasMissingEntity && (
504
+ <VisuallyHidden id={ missingEntityDescriptionId }>
505
+ <MissingEntityHelpText type={ type } kind={ kind } />
506
+ </VisuallyHidden>
507
+ ) }
485
508
  { /* eslint-disable jsx-a11y/anchor-is-valid */ }
486
509
  <a className={ classes }>
487
510
  { /* eslint-enable */ }
@@ -221,7 +221,7 @@ export function Controls( { attributes, setAttributes, clientId } ) {
221
221
  } }
222
222
  help={
223
223
  hasUrlBinding && ! isBoundEntityAvailable ? (
224
- <MissingEntityHelpText
224
+ <MissingEntityHelp
225
225
  id={ helpTextId }
226
226
  type={ attributes.type }
227
227
  kind={ attributes.kind }
@@ -327,7 +327,7 @@ export function Controls( { attributes, setAttributes, clientId } ) {
327
327
  * @param {string} props.kind - The entity kind
328
328
  * @return {string} Help text for the bound URL
329
329
  */
330
- function BindingHelpText( { type, kind } ) {
330
+ export function BindingHelpText( { type, kind } ) {
331
331
  const entityType = getEntityTypeName( type, kind );
332
332
  return sprintf(
333
333
  /* translators: %s is the entity type (e.g., "page", "post", "category") */
@@ -340,27 +340,23 @@ function BindingHelpText( { type, kind } ) {
340
340
  * Component to display error help text for missing entity bindings.
341
341
  *
342
342
  * @param {Object} props - Component props
343
- * @param {string} props.id - ID for the help text element (for aria-describedby)
344
343
  * @param {string} props.type - The entity type
345
344
  * @param {string} props.kind - The entity kind
346
345
  * @return {JSX.Element} Error help text component
347
346
  */
348
- function MissingEntityHelpText( { id, type, kind } ) {
347
+ export function MissingEntityHelpText( { type, kind } ) {
349
348
  const entityType = getEntityTypeName( type, kind );
349
+ return sprintf(
350
+ /* translators: %s is the entity type (e.g., "page", "post", "category") */
351
+ __( 'Synced %s is missing. Please update or remove this link.' ),
352
+ entityType
353
+ );
354
+ }
355
+
356
+ function MissingEntityHelp( { id, type, kind } ) {
350
357
  return (
351
- <span
352
- id={ id }
353
- className="navigation-link-control__error-text"
354
- role="alert"
355
- aria-live="polite"
356
- >
357
- { sprintf(
358
- /* translators: %s is the entity type (e.g., "page", "post", "category") */
359
- __(
360
- 'Synced %s is missing. Please update or remove this link.'
361
- ),
362
- entityType
363
- ) }
358
+ <span id={ id } className="navigation-link-control__error-text">
359
+ <MissingEntityHelpText type={ type } kind={ kind } />
364
360
  </span>
365
361
  );
366
362
  }
@@ -5,7 +5,7 @@
5
5
  * to reduce code duplication and ensure consistent behavior.
6
6
  */
7
7
 
8
- export { Controls } from './controls';
8
+ export { Controls, BindingHelpText, MissingEntityHelpText } from './controls';
9
9
  export { updateAttributes } from './update-attributes';
10
10
  export {
11
11
  useEntityBinding,
@@ -98,10 +98,13 @@ export function useEntityBinding( { clientId, attributes } ) {
98
98
 
99
99
  // Use the correct entity type based on kind.
100
100
  const entityType = isTaxonomy ? 'taxonomy' : 'postType';
101
- const entityRecord = getEntityRecord( entityType, type, id );
101
+ // Convert 'tag' back to 'post_tag' for the API call
102
+ // (it was converted from 'post_tag' to 'tag' for storage in updateAttributes)
103
+ const typeForAPI = type === 'tag' ? 'post_tag' : type;
104
+ const entityRecord = getEntityRecord( entityType, typeForAPI, id );
102
105
  const hasResolved = hasFinishedResolution( 'getEntityRecord', [
103
106
  entityType,
104
- type,
107
+ typeForAPI,
105
108
  id,
106
109
  ] );
107
110
 
@@ -9,7 +9,7 @@
9
9
  "html": false,
10
10
  "inserter": false,
11
11
  "renaming": false,
12
- "blockVisibility": false,
12
+ "visibility": false,
13
13
  "interactivity": {
14
14
  "clientNavigation": true
15
15
  }
@@ -183,7 +183,7 @@ export function SocialLinksEdit( props ) {
183
183
  <SelectControl
184
184
  __next40pxDefaultSize
185
185
  __nextHasNoMarginBottom
186
- label={ __( 'Icon Size' ) }
186
+ label={ __( 'Icon size' ) }
187
187
  onChange={ ( newSize ) => {
188
188
  setAttributes( {
189
189
  size: newSize === '' ? undefined : newSize,
package/src/style.scss CHANGED
@@ -1,3 +1,4 @@
1
+ @use "./accordion/style.scss" as *;
1
2
  @use "./accordion-item/style.scss" as *;
2
3
  @use "./accordion-heading/style.scss" as *;
3
4
  @use "./accordion-panel/style.scss" as *;