@wordpress/block-library 8.28.0 → 8.28.2

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 (78) hide show
  1. package/build/button/edit.js +1 -1
  2. package/build/button/edit.js.map +1 -1
  3. package/build/button/index.js +0 -1
  4. package/build/button/index.js.map +1 -1
  5. package/build/heading/index.js +0 -1
  6. package/build/heading/index.js.map +1 -1
  7. package/build/image/edit.js +1 -1
  8. package/build/image/edit.js.map +1 -1
  9. package/build/image/image.js +72 -6
  10. package/build/image/image.js.map +1 -1
  11. package/build/image/index.js +1 -1
  12. package/build/navigation/constants.js +1 -2
  13. package/build/navigation/constants.js.map +1 -1
  14. package/build/navigation/edit/index.js +0 -4
  15. package/build/navigation/edit/index.js.map +1 -1
  16. package/build/navigation/view.js +0 -23
  17. package/build/navigation/view.js.map +1 -1
  18. package/build/paragraph/index.js +1 -1
  19. package/build/paragraph/transforms.js +1 -1
  20. package/build/spacer/edit.js +5 -2
  21. package/build/spacer/edit.js.map +1 -1
  22. package/build-module/button/edit.js +1 -1
  23. package/build-module/button/edit.js.map +1 -1
  24. package/build-module/button/index.js +0 -1
  25. package/build-module/button/index.js.map +1 -1
  26. package/build-module/heading/index.js +0 -1
  27. package/build-module/heading/index.js.map +1 -1
  28. package/build-module/image/edit.js +1 -1
  29. package/build-module/image/edit.js.map +1 -1
  30. package/build-module/image/image.js +73 -7
  31. package/build-module/image/image.js.map +1 -1
  32. package/build-module/image/index.js +1 -1
  33. package/build-module/navigation/constants.js +0 -1
  34. package/build-module/navigation/constants.js.map +1 -1
  35. package/build-module/navigation/edit/index.js +1 -5
  36. package/build-module/navigation/edit/index.js.map +1 -1
  37. package/build-module/navigation/view.js +0 -23
  38. package/build-module/navigation/view.js.map +1 -1
  39. package/build-module/paragraph/index.js +1 -1
  40. package/build-module/paragraph/transforms.js +1 -1
  41. package/build-module/spacer/edit.js +5 -2
  42. package/build-module/spacer/edit.js.map +1 -1
  43. package/build-style/editor-rtl.css +9 -2
  44. package/build-style/editor.css +9 -2
  45. package/build-style/image/editor-rtl.css +4 -0
  46. package/build-style/image/editor.css +4 -0
  47. package/build-style/navigation/editor-rtl.css +4 -2
  48. package/build-style/navigation/editor.css +4 -2
  49. package/build-style/navigation/style-rtl.css +18 -14
  50. package/build-style/navigation/style.css +18 -14
  51. package/build-style/spacer/editor-rtl.css +1 -0
  52. package/build-style/spacer/editor.css +1 -0
  53. package/build-style/style-rtl.css +18 -14
  54. package/build-style/style.css +18 -14
  55. package/package.json +34 -34
  56. package/src/button/block.json +0 -1
  57. package/src/button/edit.js +1 -1
  58. package/src/file/index.php +1 -1
  59. package/src/footnotes/index.php +24 -11
  60. package/src/heading/block.json +0 -1
  61. package/src/image/block.json +1 -6
  62. package/src/image/edit.js +1 -1
  63. package/src/image/editor.scss +5 -0
  64. package/src/image/image.js +115 -5
  65. package/src/image/index.php +2 -2
  66. package/src/navigation/constants.js +0 -2
  67. package/src/navigation/edit/index.js +1 -11
  68. package/src/navigation/editor.scss +1 -1
  69. package/src/navigation/index.php +100 -61
  70. package/src/navigation/style.scss +16 -18
  71. package/src/navigation/view.js +0 -26
  72. package/src/navigation-link/index.php +0 -1
  73. package/src/paragraph/block.json +1 -1
  74. package/src/query/index.php +1 -1
  75. package/src/query-pagination-numbers/index.php +9 -6
  76. package/src/search/index.php +14 -6
  77. package/src/spacer/edit.js +7 -2
  78. package/src/spacer/editor.scss +2 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wordpress/block-library",
3
- "version": "8.28.0",
3
+ "version": "8.28.2",
4
4
  "description": "Block library for the WordPress editor.",
5
5
  "author": "The WordPress Contributors",
6
6
  "license": "GPL-2.0-or-later",
@@ -31,38 +31,38 @@
31
31
  ],
32
32
  "dependencies": {
33
33
  "@babel/runtime": "^7.16.0",
34
- "@wordpress/a11y": "^3.51.0",
35
- "@wordpress/api-fetch": "^6.48.0",
36
- "@wordpress/autop": "^3.51.0",
37
- "@wordpress/blob": "^3.51.0",
38
- "@wordpress/block-editor": "^12.19.0",
39
- "@wordpress/blocks": "^12.28.0",
40
- "@wordpress/components": "^26.0.0",
41
- "@wordpress/compose": "^6.28.0",
42
- "@wordpress/core-data": "^6.28.0",
43
- "@wordpress/data": "^9.21.0",
44
- "@wordpress/date": "^4.51.0",
45
- "@wordpress/deprecated": "^3.51.0",
46
- "@wordpress/dom": "^3.51.0",
47
- "@wordpress/element": "^5.28.0",
48
- "@wordpress/escape-html": "^2.51.0",
49
- "@wordpress/hooks": "^3.51.0",
50
- "@wordpress/html-entities": "^3.51.0",
51
- "@wordpress/i18n": "^4.51.0",
52
- "@wordpress/icons": "^9.42.0",
53
- "@wordpress/interactivity": "^5.0.0",
54
- "@wordpress/interactivity-router": "^1.1.0",
55
- "@wordpress/keycodes": "^3.51.0",
56
- "@wordpress/notices": "^4.19.0",
57
- "@wordpress/patterns": "^1.12.0",
58
- "@wordpress/primitives": "^3.49.0",
59
- "@wordpress/private-apis": "^0.33.0",
60
- "@wordpress/reusable-blocks": "^4.28.0",
61
- "@wordpress/rich-text": "^6.28.0",
62
- "@wordpress/server-side-render": "^4.28.0",
63
- "@wordpress/url": "^3.52.0",
64
- "@wordpress/viewport": "^5.28.0",
65
- "@wordpress/wordcount": "^3.51.0",
34
+ "@wordpress/a11y": "^3.51.1",
35
+ "@wordpress/api-fetch": "^6.48.1",
36
+ "@wordpress/autop": "^3.51.1",
37
+ "@wordpress/blob": "^3.51.1",
38
+ "@wordpress/block-editor": "^12.19.2",
39
+ "@wordpress/blocks": "^12.28.2",
40
+ "@wordpress/components": "^26.0.2",
41
+ "@wordpress/compose": "^6.28.1",
42
+ "@wordpress/core-data": "^6.28.2",
43
+ "@wordpress/data": "^9.21.1",
44
+ "@wordpress/date": "^4.51.1",
45
+ "@wordpress/deprecated": "^3.51.1",
46
+ "@wordpress/dom": "^3.51.1",
47
+ "@wordpress/element": "^5.28.1",
48
+ "@wordpress/escape-html": "^2.51.1",
49
+ "@wordpress/hooks": "^3.51.1",
50
+ "@wordpress/html-entities": "^3.51.1",
51
+ "@wordpress/i18n": "^4.51.1",
52
+ "@wordpress/icons": "^9.42.1",
53
+ "@wordpress/interactivity": "^5.0.1",
54
+ "@wordpress/interactivity-router": "^1.1.1",
55
+ "@wordpress/keycodes": "^3.51.1",
56
+ "@wordpress/notices": "^4.19.1",
57
+ "@wordpress/patterns": "^1.12.2",
58
+ "@wordpress/primitives": "^3.49.1",
59
+ "@wordpress/private-apis": "^0.33.1",
60
+ "@wordpress/reusable-blocks": "^4.28.2",
61
+ "@wordpress/rich-text": "^6.28.2",
62
+ "@wordpress/server-side-render": "^4.28.2",
63
+ "@wordpress/url": "^3.52.1",
64
+ "@wordpress/viewport": "^5.28.1",
65
+ "@wordpress/wordcount": "^3.51.1",
66
66
  "change-case": "^4.1.2",
67
67
  "classnames": "^2.3.1",
68
68
  "colord": "^2.7.0",
@@ -80,5 +80,5 @@
80
80
  "publishConfig": {
81
81
  "access": "public"
82
82
  },
83
- "gitHead": "eb796371e9630636a4a8837033807b0c4a06ed67"
83
+ "gitHead": "730beb7fd33d3382d6032c3f33e451625a0fcf36"
84
84
  }
@@ -8,7 +8,6 @@
8
8
  "description": "Prompt visitors to take action with a button-style link.",
9
9
  "keywords": [ "link" ],
10
10
  "textdomain": "default",
11
- "usesContext": [ "pattern/overrides" ],
12
11
  "attributes": {
13
12
  "tagName": {
14
13
  "type": "string",
@@ -246,7 +246,7 @@ function ButtonEdit( props ) {
246
246
  lockUrlControls:
247
247
  !! metadata?.bindings?.url &&
248
248
  getBlockBindingsSource( metadata?.bindings?.url?.source )
249
- ?.lockAttributesEditing === true,
249
+ ?.lockAttributesEditing,
250
250
  };
251
251
  },
252
252
  [ isSelected ]
@@ -53,7 +53,7 @@ function render_block_core_file( $attributes, $content ) {
53
53
 
54
54
  $processor = new WP_HTML_Tag_Processor( $content );
55
55
  $processor->next_tag();
56
- $processor->set_attribute( 'data-wp-interactive', '{"namespace":"core/file"}' );
56
+ $processor->set_attribute( 'data-wp-interactive', 'core/file' );
57
57
  $processor->next_tag( 'object' );
58
58
  $processor->set_attribute( 'data-wp-bind--hidden', '!state.hasPdfPreview' );
59
59
  $processor->set_attribute( 'hidden', true );
@@ -68,15 +68,30 @@ function render_block_core_footnotes( $attributes, $content, $block ) {
68
68
  * @since 6.3.0
69
69
  */
70
70
  function register_block_core_footnotes() {
71
- $post_types = get_post_types(
71
+ register_block_type_from_metadata(
72
+ __DIR__ . '/footnotes',
72
73
  array(
73
- 'show_in_rest' => true,
74
- 'public' => true,
74
+ 'render_callback' => 'render_block_core_footnotes',
75
75
  )
76
76
  );
77
+ }
78
+ add_action( 'init', 'register_block_core_footnotes' );
79
+
80
+
81
+ /**
82
+ * Registers the footnotes meta field required for footnotes to work.
83
+ *
84
+ * @since 6.5.0
85
+ */
86
+ function register_block_core_footnotes_post_meta() {
87
+ $post_types = get_post_types( array( 'show_in_rest' => true ) );
77
88
  foreach ( $post_types as $post_type ) {
78
89
  // Only register the meta field if the post type supports the editor, custom fields, and revisions.
79
- if ( post_type_supports( $post_type, 'editor' ) && post_type_supports( $post_type, 'custom-fields' ) && post_type_supports( $post_type, 'revisions' ) ) {
90
+ if (
91
+ post_type_supports( $post_type, 'editor' ) &&
92
+ post_type_supports( $post_type, 'custom-fields' ) &&
93
+ post_type_supports( $post_type, 'revisions' )
94
+ ) {
80
95
  register_post_meta(
81
96
  $post_type,
82
97
  'footnotes',
@@ -89,14 +104,12 @@ function register_block_core_footnotes() {
89
104
  );
90
105
  }
91
106
  }
92
- register_block_type_from_metadata(
93
- __DIR__ . '/footnotes',
94
- array(
95
- 'render_callback' => 'render_block_core_footnotes',
96
- )
97
- );
98
107
  }
99
- add_action( 'init', 'register_block_core_footnotes' );
108
+ /**
109
+ * Most post types are registered at priority 10, so use priority 20 here in
110
+ * order to catch them.
111
+ */
112
+ add_action( 'init', 'register_block_core_footnotes_post_meta', 20 );
100
113
 
101
114
  /**
102
115
  * Adds the footnotes field to the revisions display.
@@ -7,7 +7,6 @@
7
7
  "description": "Introduce new sections and organize content to help visitors (and search engines) understand the structure of your content.",
8
8
  "keywords": [ "title", "subtitle" ],
9
9
  "textdomain": "default",
10
- "usesContext": [ "pattern/overrides" ],
11
10
  "attributes": {
12
11
  "textAlign": {
13
12
  "type": "string"
@@ -4,12 +4,7 @@
4
4
  "name": "core/image",
5
5
  "title": "Image",
6
6
  "category": "media",
7
- "usesContext": [
8
- "allowResize",
9
- "imageCrop",
10
- "fixedHeight",
11
- "pattern/overrides"
12
- ],
7
+ "usesContext": [ "allowResize", "imageCrop", "fixedHeight" ],
13
8
  "description": "Insert an image to make a visual statement.",
14
9
  "keywords": [ "img", "photo", "picture" ],
15
10
  "textdomain": "default",
package/src/image/edit.js CHANGED
@@ -349,7 +349,7 @@ export function ImageEdit( {
349
349
  lockUrlControls:
350
350
  !! metadata?.bindings?.url &&
351
351
  getBlockBindingsSource( metadata?.bindings?.url?.source )
352
- ?.lockAttributesEditing === true,
352
+ ?.lockAttributesEditing,
353
353
  };
354
354
  },
355
355
  [ isSingleSelected ]
@@ -181,3 +181,8 @@ figure.wp-block-image:not(.wp-block) {
181
181
  padding-right: 0;
182
182
  }
183
183
  }
184
+
185
+ .wp-block-image__toolbar_content_textarea {
186
+ // Corresponds to the size of the textarea in the block inspector.
187
+ width: 250px;
188
+ }
@@ -10,6 +10,7 @@ import {
10
10
  TextControl,
11
11
  ToolbarButton,
12
12
  ToolbarGroup,
13
+ Dropdown,
13
14
  __experimentalToolsPanel as ToolsPanel,
14
15
  __experimentalToolsPanelItem as ToolsPanelItem,
15
16
  __experimentalUseCustomUnits as useCustomUnits,
@@ -30,6 +31,7 @@ import {
30
31
  } from '@wordpress/block-editor';
31
32
  import { useEffect, useMemo, useState, useRef } from '@wordpress/element';
32
33
  import { __, _x, sprintf, isRTL } from '@wordpress/i18n';
34
+ import { DOWN } from '@wordpress/keycodes';
33
35
  import { getFilename } from '@wordpress/url';
34
36
  import { switchToBlockType } from '@wordpress/blocks';
35
37
  import { crop, overlayText, upload } from '@wordpress/icons';
@@ -177,6 +179,7 @@ export default function Image( {
177
179
  const [ externalBlob, setExternalBlob ] = useState();
178
180
  const clientWidth = useClientWidth( containerRef, [ align ] );
179
181
  const hasNonContentControls = blockEditingMode === 'default';
182
+ const isContentOnlyMode = blockEditingMode === 'contentOnly';
180
183
  const isResizable =
181
184
  allowResize &&
182
185
  hasNonContentControls &&
@@ -427,7 +430,7 @@ export default function Image( {
427
430
  lockUrlControls:
428
431
  !! urlBinding &&
429
432
  getBlockBindingsSource( urlBinding?.source )
430
- ?.lockAttributesEditing === true,
433
+ ?.lockAttributesEditing,
431
434
  lockHrefControls:
432
435
  // Disable editing the link of the URL if the image is inside a pattern instance.
433
436
  // This is a temporary solution until we support overriding the link on the frontend.
@@ -435,11 +438,11 @@ export default function Image( {
435
438
  lockAltControls:
436
439
  !! altBinding &&
437
440
  getBlockBindingsSource( altBinding?.source )
438
- ?.lockAttributesEditing === true,
441
+ ?.lockAttributesEditing,
439
442
  lockTitleControls:
440
443
  !! titleBinding &&
441
444
  getBlockBindingsSource( titleBinding?.source )
442
- ?.lockAttributesEditing === true,
445
+ ?.lockAttributesEditing,
443
446
  };
444
447
  },
445
448
  [ clientId, isSingleSelected, metadata?.bindings ]
@@ -505,6 +508,113 @@ export default function Image( {
505
508
  </ToolbarGroup>
506
509
  </BlockControls>
507
510
  ) }
511
+ { isContentOnlyMode && (
512
+ // Add some extra controls for content attributes when content only mode is active.
513
+ // With content only mode active, the inspector is hidden, so users need another way
514
+ // to edit these attributes.
515
+ <BlockControls group="other">
516
+ <Dropdown
517
+ popoverProps={ { position: 'bottom right' } }
518
+ renderToggle={ ( { isOpen, onToggle } ) => (
519
+ <ToolbarButton
520
+ onClick={ onToggle }
521
+ aria-haspopup="true"
522
+ aria-expanded={ isOpen }
523
+ onKeyDown={ ( event ) => {
524
+ if ( ! isOpen && event.keyCode === DOWN ) {
525
+ event.preventDefault();
526
+ onToggle();
527
+ }
528
+ } }
529
+ >
530
+ { _x(
531
+ 'Alt',
532
+ 'Alternative text for an image. Block toolbar label, a low character count is preferred.'
533
+ ) }
534
+ </ToolbarButton>
535
+ ) }
536
+ renderContent={ () => (
537
+ <TextareaControl
538
+ className="wp-block-image__toolbar_content_textarea"
539
+ label={ __( 'Alternative text' ) }
540
+ value={ alt || '' }
541
+ onChange={ updateAlt }
542
+ disabled={ lockAltControls }
543
+ help={
544
+ lockAltControls ? (
545
+ <>
546
+ { __(
547
+ 'Connected to a custom field'
548
+ ) }
549
+ </>
550
+ ) : (
551
+ <>
552
+ <ExternalLink href="https://www.w3.org/WAI/tutorials/images/decision-tree">
553
+ { __(
554
+ 'Describe the purpose of the image.'
555
+ ) }
556
+ </ExternalLink>
557
+ <br />
558
+ { __(
559
+ 'Leave empty if decorative.'
560
+ ) }
561
+ </>
562
+ )
563
+ }
564
+ __nextHasNoMarginBottom
565
+ />
566
+ ) }
567
+ />
568
+ <Dropdown
569
+ popoverProps={ { position: 'bottom right' } }
570
+ renderToggle={ ( { isOpen, onToggle } ) => (
571
+ <ToolbarButton
572
+ onClick={ onToggle }
573
+ aria-haspopup="true"
574
+ aria-expanded={ isOpen }
575
+ onKeyDown={ ( event ) => {
576
+ if ( ! isOpen && event.keyCode === DOWN ) {
577
+ event.preventDefault();
578
+ onToggle();
579
+ }
580
+ } }
581
+ >
582
+ { __( 'Title' ) }
583
+ </ToolbarButton>
584
+ ) }
585
+ renderContent={ () => (
586
+ <TextControl
587
+ className="wp-block-image__toolbar_content_textarea"
588
+ __nextHasNoMarginBottom
589
+ label={ __( 'Title attribute' ) }
590
+ value={ title || '' }
591
+ onChange={ onSetTitle }
592
+ disabled={ lockTitleControls }
593
+ help={
594
+ lockTitleControls ? (
595
+ <>
596
+ { __(
597
+ 'Connected to a custom field'
598
+ ) }
599
+ </>
600
+ ) : (
601
+ <>
602
+ { __(
603
+ 'Describe the role of this image on the page.'
604
+ ) }
605
+ <ExternalLink href="https://www.w3.org/TR/html52/dom.html#the-title-attribute">
606
+ { __(
607
+ '(Note: many devices and browsers do not display this text.)'
608
+ ) }
609
+ </ExternalLink>
610
+ </>
611
+ )
612
+ }
613
+ />
614
+ ) }
615
+ />
616
+ </BlockControls>
617
+ ) }
508
618
  <InspectorControls>
509
619
  <ToolsPanel
510
620
  label={ __( 'Settings' ) }
@@ -524,7 +634,7 @@ export default function Image( {
524
634
  label={ __( 'Alternative text' ) }
525
635
  value={ alt || '' }
526
636
  onChange={ updateAlt }
527
- disabled={ lockAltControls }
637
+ readOnly={ lockAltControls }
528
638
  help={
529
639
  lockAltControls ? (
530
640
  <>
@@ -566,7 +676,7 @@ export default function Image( {
566
676
  label={ __( 'Title attribute' ) }
567
677
  value={ title || '' }
568
678
  onChange={ onSetTitle }
569
- disabled={ lockTitleControls }
679
+ readOnly={ lockTitleControls }
570
680
  help={
571
681
  lockTitleControls ? (
572
682
  <>{ __( 'Connected to a custom field' ) }</>
@@ -159,7 +159,7 @@ function block_core_image_render_lightbox( $block_content, $block ) {
159
159
  $figure_class_names = $p->get_attribute( 'class' );
160
160
  $figure_styles = $p->get_attribute( 'style' );
161
161
  $p->add_class( 'wp-lightbox-container' );
162
- $p->set_attribute( 'data-wp-interactive', '{"namespace":"core/image"}' );
162
+ $p->set_attribute( 'data-wp-interactive', 'core/image' );
163
163
  $p->set_attribute(
164
164
  'data-wp-context',
165
165
  wp_json_encode(
@@ -240,7 +240,7 @@ function block_core_image_print_lightbox_overlay() {
240
240
  echo <<<HTML
241
241
  <div
242
242
  class="wp-lightbox-overlay zoom"
243
- data-wp-interactive='{"namespace":"core/image"}'
243
+ data-wp-interactive="core/image"
244
244
  data-wp-context='{}'
245
245
  data-wp-bind--role="state.roleAttribute"
246
246
  data-wp-bind--aria-label="state.currentImage.ariaLabel"
@@ -23,5 +23,3 @@ export const SELECT_NAVIGATION_MENUS_ARGS = [
23
23
  'wp_navigation',
24
24
  PRELOADED_NAVIGATION_MENUS_QUERY,
25
25
  ];
26
-
27
- export const NAVIGATION_MOBILE_COLLAPSE = '600px';
@@ -42,7 +42,7 @@ import {
42
42
  import { __, sprintf } from '@wordpress/i18n';
43
43
  import { speak } from '@wordpress/a11y';
44
44
  import { close, Icon } from '@wordpress/icons';
45
- import { useInstanceId, useMediaQuery } from '@wordpress/compose';
45
+ import { useInstanceId } from '@wordpress/compose';
46
46
 
47
47
  /**
48
48
  * Internal dependencies
@@ -71,7 +71,6 @@ import MenuInspectorControls from './menu-inspector-controls';
71
71
  import DeletedNavigationWarning from './deleted-navigation-warning';
72
72
  import AccessibleDescription from './accessible-description';
73
73
  import AccessibleMenuDescription from './accessible-menu-description';
74
- import { NAVIGATION_MOBILE_COLLAPSE } from '../constants';
75
74
  import { unlock } from '../../lock-unlock';
76
75
 
77
76
  function Navigation( {
@@ -298,14 +297,6 @@ function Navigation( {
298
297
  [ clientId ]
299
298
  );
300
299
  const isResponsive = 'never' !== overlayMenu;
301
- const isMobileBreakPoint = useMediaQuery(
302
- `(max-width: ${ NAVIGATION_MOBILE_COLLAPSE })`
303
- );
304
-
305
- const isCollapsed =
306
- ( 'mobile' === overlayMenu && isMobileBreakPoint ) ||
307
- 'always' === overlayMenu;
308
-
309
300
  const blockProps = useBlockProps( {
310
301
  ref: navRef,
311
302
  className: classnames(
@@ -319,7 +310,6 @@ function Navigation( {
319
310
  'is-vertical': orientation === 'vertical',
320
311
  'no-wrap': flexWrap === 'nowrap',
321
312
  'is-responsive': isResponsive,
322
- 'is-collapsed': isCollapsed,
323
313
  'has-text-color': !! textColor.color || !! textColor?.class,
324
314
  [ getColorClassName( 'color', textColor?.slug ) ]:
325
315
  !! textColor?.slug,
@@ -429,7 +429,7 @@ $color-control-label-height: 20px;
429
429
  // These needs extra specificity in the editor.
430
430
  .wp-block-navigation__responsive-container:not(.is-menu-open) {
431
431
  .components-button.wp-block-navigation__responsive-container-close {
432
- .is-collapsed & {
432
+ @include break-small {
433
433
  display: none;
434
434
  }
435
435
  }