@wordpress/block-library 8.28.3 → 8.28.5

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 (110) hide show
  1. package/build/block/deprecated.js +71 -11
  2. package/build/block/deprecated.js.map +1 -1
  3. package/build/block/edit.js +49 -24
  4. package/build/block/edit.js.map +1 -1
  5. package/build/button/edit.js +1 -1
  6. package/build/button/edit.js.map +1 -1
  7. package/build/buttons/transforms.js +16 -2
  8. package/build/buttons/transforms.js.map +1 -1
  9. package/build/code/transforms.js +17 -6
  10. package/build/code/transforms.js.map +1 -1
  11. package/build/cover/edit/block-controls.js +14 -3
  12. package/build/cover/edit/block-controls.js.map +1 -1
  13. package/build/cover/edit/inspector-controls.js +1 -1
  14. package/build/cover/edit/inspector-controls.js.map +1 -1
  15. package/build/heading/transforms.js +17 -4
  16. package/build/heading/transforms.js.map +1 -1
  17. package/build/image/edit.js +8 -4
  18. package/build/image/edit.js.map +1 -1
  19. package/build/image/image.js +22 -8
  20. package/build/image/image.js.map +1 -1
  21. package/build/list-item/edit.js +1 -3
  22. package/build/list-item/edit.js.map +1 -1
  23. package/build/list-item/hooks/index.js +0 -7
  24. package/build/list-item/hooks/index.js.map +1 -1
  25. package/build/list-item/index.js +4 -1
  26. package/build/list-item/index.js.map +1 -1
  27. package/build/post-featured-image/edit.js +8 -11
  28. package/build/post-featured-image/edit.js.map +1 -1
  29. package/build/post-title/edit.js +2 -2
  30. package/build/post-title/edit.js.map +1 -1
  31. package/build/site-logo/edit.js +7 -2
  32. package/build/site-logo/edit.js.map +1 -1
  33. package/build/utils/caption.js +15 -5
  34. package/build/utils/caption.js.map +1 -1
  35. package/build/utils/get-transformed-metadata.js +57 -0
  36. package/build/utils/get-transformed-metadata.js.map +1 -0
  37. package/build-module/block/deprecated.js +71 -11
  38. package/build-module/block/deprecated.js.map +1 -1
  39. package/build-module/block/edit.js +49 -24
  40. package/build-module/block/edit.js.map +1 -1
  41. package/build-module/button/edit.js +2 -2
  42. package/build-module/button/edit.js.map +1 -1
  43. package/build-module/buttons/transforms.js +16 -2
  44. package/build-module/buttons/transforms.js.map +1 -1
  45. package/build-module/code/transforms.js +17 -6
  46. package/build-module/code/transforms.js.map +1 -1
  47. package/build-module/cover/edit/block-controls.js +15 -4
  48. package/build-module/cover/edit/block-controls.js.map +1 -1
  49. package/build-module/cover/edit/inspector-controls.js +1 -1
  50. package/build-module/cover/edit/inspector-controls.js.map +1 -1
  51. package/build-module/heading/transforms.js +17 -4
  52. package/build-module/heading/transforms.js.map +1 -1
  53. package/build-module/image/edit.js +9 -5
  54. package/build-module/image/edit.js.map +1 -1
  55. package/build-module/image/image.js +23 -9
  56. package/build-module/image/image.js.map +1 -1
  57. package/build-module/list-item/edit.js +2 -4
  58. package/build-module/list-item/edit.js.map +1 -1
  59. package/build-module/list-item/hooks/index.js +0 -1
  60. package/build-module/list-item/hooks/index.js.map +1 -1
  61. package/build-module/list-item/index.js +4 -1
  62. package/build-module/list-item/index.js.map +1 -1
  63. package/build-module/post-featured-image/edit.js +9 -12
  64. package/build-module/post-featured-image/edit.js.map +1 -1
  65. package/build-module/post-title/edit.js +2 -2
  66. package/build-module/post-title/edit.js.map +1 -1
  67. package/build-module/site-logo/edit.js +7 -2
  68. package/build-module/site-logo/edit.js.map +1 -1
  69. package/build-module/utils/caption.js +13 -3
  70. package/build-module/utils/caption.js.map +1 -1
  71. package/build-module/utils/get-transformed-metadata.js +51 -0
  72. package/build-module/utils/get-transformed-metadata.js.map +1 -0
  73. package/build-style/common-rtl.css +1 -0
  74. package/build-style/common.css +1 -0
  75. package/build-style/cover/style-rtl.css +2 -1
  76. package/build-style/cover/style.css +2 -1
  77. package/build-style/search/style-rtl.css +2 -0
  78. package/build-style/search/style.css +2 -0
  79. package/build-style/style-rtl.css +4 -1
  80. package/build-style/style.css +4 -1
  81. package/package.json +13 -13
  82. package/src/block/deprecated.js +76 -11
  83. package/src/block/edit.js +64 -19
  84. package/src/block/index.php +21 -12
  85. package/src/button/edit.js +2 -1
  86. package/src/buttons/transforms.js +14 -4
  87. package/src/code/transforms.js +20 -5
  88. package/src/cover/edit/block-controls.js +16 -2
  89. package/src/cover/edit/inspector-controls.js +5 -1
  90. package/src/cover/style.scss +3 -2
  91. package/src/footnotes/index.php +1 -1
  92. package/src/heading/transforms.js +27 -8
  93. package/src/image/edit.js +12 -4
  94. package/src/image/image.js +32 -20
  95. package/src/list-item/edit.js +1 -2
  96. package/src/list-item/hooks/index.js +0 -1
  97. package/src/list-item/index.js +3 -0
  98. package/src/navigation/index.php +8 -4
  99. package/src/post-featured-image/edit.js +9 -11
  100. package/src/post-title/edit.js +49 -43
  101. package/src/search/index.php +1 -1
  102. package/src/search/style.scss +2 -0
  103. package/src/site-logo/edit.js +10 -5
  104. package/src/utils/caption.js +10 -1
  105. package/src/utils/get-transformed-metadata.js +65 -0
  106. package/build/list-item/hooks/use-copy.js +0 -39
  107. package/build/list-item/hooks/use-copy.js.map +0 -1
  108. package/build-module/list-item/hooks/use-copy.js +0 -32
  109. package/build-module/list-item/hooks/use-copy.js.map +0 -1
  110. package/src/list-item/hooks/use-copy.js +0 -38
package/src/image/edit.js CHANGED
@@ -7,6 +7,7 @@ import classnames from 'classnames';
7
7
  * WordPress dependencies
8
8
  */
9
9
  import { getBlobByURL, isBlobURL, revokeBlobURL } from '@wordpress/blob';
10
+ import { store as blocksStore } from '@wordpress/blocks';
10
11
  import { Placeholder } from '@wordpress/components';
11
12
  import { useDispatch, useSelect } from '@wordpress/data';
12
13
  import {
@@ -19,7 +20,7 @@ import {
19
20
  useBlockEditingMode,
20
21
  } from '@wordpress/block-editor';
21
22
  import { useEffect, useRef, useState } from '@wordpress/element';
22
- import { __ } from '@wordpress/i18n';
23
+ import { __, sprintf } from '@wordpress/i18n';
23
24
  import { image as icon, plugins as pluginsIcon } from '@wordpress/icons';
24
25
  import { store as noticesStore } from '@wordpress/notices';
25
26
 
@@ -335,14 +336,14 @@ export function ImageEdit( {
335
336
  } );
336
337
 
337
338
  // Much of this description is duplicated from MediaPlaceholder.
338
- const { lockUrlControls = false } = useSelect(
339
+ const { lockUrlControls = false, lockUrlControlsMessage } = useSelect(
339
340
  ( select ) => {
340
341
  if ( ! isSingleSelected ) {
341
342
  return {};
342
343
  }
343
344
 
344
345
  const blockBindingsSource = unlock(
345
- select( blockEditorStore )
346
+ select( blocksStore )
346
347
  ).getBlockBindingsSource( metadata?.bindings?.url?.source );
347
348
 
348
349
  return {
@@ -350,6 +351,13 @@ export function ImageEdit( {
350
351
  !! metadata?.bindings?.url &&
351
352
  ( ! blockBindingsSource ||
352
353
  blockBindingsSource?.lockAttributesEditing ),
354
+ lockUrlControlsMessage: blockBindingsSource?.label
355
+ ? sprintf(
356
+ /* translators: %s: Label of the bindings source. */
357
+ __( 'Connected to %s' ),
358
+ blockBindingsSource.label
359
+ )
360
+ : __( 'Connected to dynamic data' ),
353
361
  };
354
362
  },
355
363
  [ isSingleSelected ]
@@ -386,7 +394,7 @@ export function ImageEdit( {
386
394
  <span
387
395
  className={ 'block-bindings-media-placeholder-message' }
388
396
  >
389
- { __( 'Connected to a custom field' ) }
397
+ { lockUrlControlsMessage }
390
398
  </span>
391
399
  ) : (
392
400
  content
@@ -33,7 +33,7 @@ import { useEffect, useMemo, useState, useRef } from '@wordpress/element';
33
33
  import { __, _x, sprintf, isRTL } from '@wordpress/i18n';
34
34
  import { DOWN } from '@wordpress/keycodes';
35
35
  import { getFilename } from '@wordpress/url';
36
- import { switchToBlockType } from '@wordpress/blocks';
36
+ import { switchToBlockType, store as blocksStore } from '@wordpress/blocks';
37
37
  import { crop, overlayText, upload } from '@wordpress/icons';
38
38
  import { store as noticesStore } from '@wordpress/notices';
39
39
  import { store as coreStore } from '@wordpress/core-data';
@@ -410,15 +410,19 @@ export default function Image( {
410
410
  lockUrlControls = false,
411
411
  lockHrefControls = false,
412
412
  lockAltControls = false,
413
+ lockAltControlsMessage,
413
414
  lockTitleControls = false,
415
+ lockTitleControlsMessage,
416
+ lockCaption = false,
414
417
  } = useSelect(
415
418
  ( select ) => {
416
419
  if ( ! isSingleSelected ) {
417
420
  return {};
418
421
  }
419
-
420
- const { getBlockBindingsSource, getBlockParentsByBlockName } =
421
- unlock( select( blockEditorStore ) );
422
+ const { getBlockBindingsSource } = unlock( select( blocksStore ) );
423
+ const { getBlockParentsByBlockName } = unlock(
424
+ select( blockEditorStore )
425
+ );
422
426
  const {
423
427
  url: urlBinding,
424
428
  alt: altBinding,
@@ -444,14 +448,32 @@ export default function Image( {
444
448
  // Disable editing the link of the URL if the image is inside a pattern instance.
445
449
  // This is a temporary solution until we support overriding the link on the frontend.
446
450
  hasParentPattern,
451
+ lockCaption:
452
+ // Disable editing the caption if the image is inside a pattern instance.
453
+ // This is a temporary solution until we support overriding the caption on the frontend.
454
+ hasParentPattern,
447
455
  lockAltControls:
448
456
  !! altBinding &&
449
457
  ( ! altBindingSource ||
450
458
  altBindingSource?.lockAttributesEditing ),
459
+ lockAltControlsMessage: altBindingSource?.label
460
+ ? sprintf(
461
+ /* translators: %s: Label of the bindings source. */
462
+ __( 'Connected to %s' ),
463
+ altBindingSource.label
464
+ )
465
+ : __( 'Connected to dynamic data' ),
451
466
  lockTitleControls:
452
467
  !! titleBinding &&
453
468
  ( ! titleBindingSource ||
454
469
  titleBindingSource?.lockAttributesEditing ),
470
+ lockTitleControlsMessage: titleBindingSource?.label
471
+ ? sprintf(
472
+ /* translators: %s: Label of the bindings source. */
473
+ __( 'Connected to %s' ),
474
+ titleBindingSource.label
475
+ )
476
+ : __( 'Connected to dynamic data' ),
455
477
  };
456
478
  },
457
479
  [ clientId, isSingleSelected, metadata?.bindings ]
@@ -551,11 +573,7 @@ export default function Image( {
551
573
  disabled={ lockAltControls }
552
574
  help={
553
575
  lockAltControls ? (
554
- <>
555
- { __(
556
- 'Connected to a custom field'
557
- ) }
558
- </>
576
+ <>{ lockAltControlsMessage }</>
559
577
  ) : (
560
578
  <>
561
579
  <ExternalLink href="https://www.w3.org/WAI/tutorials/images/decision-tree">
@@ -601,11 +619,7 @@ export default function Image( {
601
619
  disabled={ lockTitleControls }
602
620
  help={
603
621
  lockTitleControls ? (
604
- <>
605
- { __(
606
- 'Connected to a custom field'
607
- ) }
608
- </>
622
+ <>{ lockTitleControlsMessage }</>
609
623
  ) : (
610
624
  <>
611
625
  { __(
@@ -646,11 +660,7 @@ export default function Image( {
646
660
  readOnly={ lockAltControls }
647
661
  help={
648
662
  lockAltControls ? (
649
- <>
650
- { __(
651
- 'Connected to a custom field'
652
- ) }
653
- </>
663
+ <>{ lockAltControlsMessage }</>
654
664
  ) : (
655
665
  <>
656
666
  <ExternalLink href="https://www.w3.org/WAI/tutorials/images/decision-tree">
@@ -688,7 +698,7 @@ export default function Image( {
688
698
  readOnly={ lockTitleControls }
689
699
  help={
690
700
  lockTitleControls ? (
691
- <>{ __( 'Connected to a custom field' ) }</>
701
+ <>{ lockTitleControlsMessage }</>
692
702
  ) : (
693
703
  <>
694
704
  { __(
@@ -907,6 +917,7 @@ export default function Image( {
907
917
  which causes duplicated image upload. */ }
908
918
  { ! temporaryURL && controls }
909
919
  { img }
920
+
910
921
  <Caption
911
922
  attributes={ attributes }
912
923
  setAttributes={ setAttributes }
@@ -914,6 +925,7 @@ export default function Image( {
914
925
  insertBlocksAfter={ insertBlocksAfter }
915
926
  label={ __( 'Image caption text' ) }
916
927
  showToolbarButton={ isSingleSelected && hasNonContentControls }
928
+ disableEditing={ lockCaption }
917
929
  />
918
930
  </>
919
931
  );
@@ -29,7 +29,6 @@ import {
29
29
  useOutdentListItem,
30
30
  useSplit,
31
31
  useMerge,
32
- useCopy,
33
32
  } from './hooks';
34
33
  import { convertToListItems } from './utils';
35
34
 
@@ -79,7 +78,7 @@ export default function ListItemEdit( {
79
78
  mergeBlocks,
80
79
  } ) {
81
80
  const { placeholder, content } = attributes;
82
- const blockProps = useBlockProps( { ref: useCopy( clientId ) } );
81
+ const blockProps = useBlockProps();
83
82
  const innerBlocksProps = useInnerBlocksProps( blockProps, {
84
83
  renderAppender: false,
85
84
  __unstableDisableDropZone: true,
@@ -4,4 +4,3 @@ export { default as useEnter } from './use-enter';
4
4
  export { default as useSpace } from './use-space';
5
5
  export { default as useSplit } from './use-split';
6
6
  export { default as useMerge } from './use-merge';
7
- export { default as useCopy } from './use-copy';
@@ -2,6 +2,7 @@
2
2
  * WordPress dependencies
3
3
  */
4
4
  import { listItem as icon } from '@wordpress/icons';
5
+ import { privateApis } from '@wordpress/block-editor';
5
6
 
6
7
  /**
7
8
  * Internal dependencies
@@ -11,6 +12,7 @@ import metadata from './block.json';
11
12
  import edit from './edit';
12
13
  import save from './save';
13
14
  import transforms from './transforms';
15
+ import { unlock } from '../lock-unlock';
14
16
 
15
17
  const { name } = metadata;
16
18
 
@@ -27,6 +29,7 @@ export const settings = {
27
29
  };
28
30
  },
29
31
  transforms,
32
+ [ unlock( privateApis ).requiresWrapperOnCopy ]: true,
30
33
  };
31
34
 
32
35
  export const init = () => initBlock( { name, metadata, settings } );
@@ -552,16 +552,20 @@ class WP_Navigation_Block_Renderer {
552
552
  return '';
553
553
  }
554
554
  // When adding to this array be mindful of security concerns.
555
- $nav_element_context = data_wp_context(
555
+ $nav_element_context = wp_interactivity_data_wp_context(
556
556
  array(
557
- 'overlayOpenedBy' => array(),
557
+ 'overlayOpenedBy' => array(
558
+ 'click' => false,
559
+ 'hover' => false,
560
+ 'focus' => false,
561
+ ),
558
562
  'type' => 'overlay',
559
563
  'roleAttribute' => '',
560
564
  'ariaLabel' => __( 'Menu' ),
561
565
  )
562
566
  );
563
567
  $nav_element_directives = '
564
- data-wp-interactive="core/navigation"'
568
+ data-wp-interactive="core/navigation" '
565
569
  . $nav_element_context;
566
570
 
567
571
  return $nav_element_directives;
@@ -764,7 +768,7 @@ function block_core_navigation_add_directives_to_submenu( $tags, $block_attribut
764
768
  ) ) {
765
769
  // Add directives to the parent `<li>`.
766
770
  $tags->set_attribute( 'data-wp-interactive', 'core/navigation' );
767
- $tags->set_attribute( 'data-wp-context', '{ "submenuOpenedBy": {}, "type": "submenu" }' );
771
+ $tags->set_attribute( 'data-wp-context', '{ "submenuOpenedBy": { "click": false, "hover": false, "focus": false }, "type": "submenu" }' );
768
772
  $tags->set_attribute( 'data-wp-watch', 'callbacks.initMenu' );
769
773
  $tags->set_attribute( 'data-wp-on--focusout', 'actions.handleMenuFocusout' );
770
774
  $tags->set_attribute( 'data-wp-on--keydown', 'actions.handleMenuKeydown' );
@@ -24,6 +24,7 @@ import {
24
24
  useBlockProps,
25
25
  store as blockEditorStore,
26
26
  __experimentalUseBorderProps as useBorderProps,
27
+ useBlockEditingMode,
27
28
  } from '@wordpress/block-editor';
28
29
  import { useMemo } from '@wordpress/element';
29
30
  import { __, sprintf } from '@wordpress/i18n';
@@ -143,6 +144,7 @@ export default function PostFeaturedImageEdit( {
143
144
  style: { width, height, aspectRatio },
144
145
  } );
145
146
  const borderProps = useBorderProps( attributes );
147
+ const blockEditingMode = useBlockEditingMode();
146
148
 
147
149
  const placeholder = ( content ) => {
148
150
  return (
@@ -174,8 +176,13 @@ export default function PostFeaturedImageEdit( {
174
176
  createErrorNotice( message, { type: 'snackbar' } );
175
177
  };
176
178
 
177
- const controls = (
179
+ const controls = blockEditingMode === 'default' && (
178
180
  <>
181
+ <Overlay
182
+ attributes={ attributes }
183
+ setAttributes={ setAttributes }
184
+ clientId={ clientId }
185
+ />
179
186
  <DimensionControls
180
187
  clientId={ clientId }
181
188
  attributes={ attributes }
@@ -224,6 +231,7 @@ export default function PostFeaturedImageEdit( {
224
231
  </InspectorControls>
225
232
  </>
226
233
  );
234
+
227
235
  let image;
228
236
 
229
237
  /**
@@ -251,11 +259,6 @@ export default function PostFeaturedImageEdit( {
251
259
  ) : (
252
260
  placeholder()
253
261
  ) }
254
- <Overlay
255
- attributes={ attributes }
256
- setAttributes={ setAttributes }
257
- clientId={ clientId }
258
- />
259
262
  </div>
260
263
  </>
261
264
  );
@@ -360,11 +363,6 @@ export default function PostFeaturedImageEdit( {
360
363
  ) : (
361
364
  image
362
365
  ) }
363
- <Overlay
364
- attributes={ attributes }
365
- setAttributes={ setAttributes }
366
- clientId={ clientId }
367
- />
368
366
  </figure>
369
367
  </>
370
368
  );
@@ -115,53 +115,59 @@ export default function PostTitleEdit( {
115
115
  return (
116
116
  <>
117
117
  { blockEditingMode === 'default' && (
118
- <BlockControls group="block">
119
- <HeadingLevelDropdown
120
- value={ level }
121
- onChange={ ( newLevel ) =>
122
- setAttributes( { level: newLevel } )
123
- }
124
- />
125
- <AlignmentControl
126
- value={ textAlign }
127
- onChange={ ( nextAlign ) => {
128
- setAttributes( { textAlign: nextAlign } );
129
- } }
130
- />
131
- </BlockControls>
132
- ) }
133
- <InspectorControls>
134
- <PanelBody title={ __( 'Settings' ) }>
135
- <ToggleControl
136
- __nextHasNoMarginBottom
137
- label={ __( 'Make title a link' ) }
138
- onChange={ () => setAttributes( { isLink: ! isLink } ) }
139
- checked={ isLink }
140
- />
141
- { isLink && (
142
- <>
118
+ <>
119
+ <BlockControls group="block">
120
+ <HeadingLevelDropdown
121
+ value={ level }
122
+ onChange={ ( newLevel ) =>
123
+ setAttributes( { level: newLevel } )
124
+ }
125
+ />
126
+ <AlignmentControl
127
+ value={ textAlign }
128
+ onChange={ ( nextAlign ) => {
129
+ setAttributes( { textAlign: nextAlign } );
130
+ } }
131
+ />
132
+ </BlockControls>
133
+ <InspectorControls>
134
+ <PanelBody title={ __( 'Settings' ) }>
143
135
  <ToggleControl
144
136
  __nextHasNoMarginBottom
145
- label={ __( 'Open in new tab' ) }
146
- onChange={ ( value ) =>
147
- setAttributes( {
148
- linkTarget: value ? '_blank' : '_self',
149
- } )
137
+ label={ __( 'Make title a link' ) }
138
+ onChange={ () =>
139
+ setAttributes( { isLink: ! isLink } )
150
140
  }
151
- checked={ linkTarget === '_blank' }
141
+ checked={ isLink }
152
142
  />
153
- <TextControl
154
- __nextHasNoMarginBottom
155
- label={ __( 'Link rel' ) }
156
- value={ rel }
157
- onChange={ ( newRel ) =>
158
- setAttributes( { rel: newRel } )
159
- }
160
- />
161
- </>
162
- ) }
163
- </PanelBody>
164
- </InspectorControls>
143
+ { isLink && (
144
+ <>
145
+ <ToggleControl
146
+ __nextHasNoMarginBottom
147
+ label={ __( 'Open in new tab' ) }
148
+ onChange={ ( value ) =>
149
+ setAttributes( {
150
+ linkTarget: value
151
+ ? '_blank'
152
+ : '_self',
153
+ } )
154
+ }
155
+ checked={ linkTarget === '_blank' }
156
+ />
157
+ <TextControl
158
+ __nextHasNoMarginBottom
159
+ label={ __( 'Link rel' ) }
160
+ value={ rel }
161
+ onChange={ ( newRel ) =>
162
+ setAttributes( { rel: newRel } )
163
+ }
164
+ />
165
+ </>
166
+ ) }
167
+ </PanelBody>
168
+ </InspectorControls>
169
+ </>
170
+ ) }
165
171
  { titleElement }
166
172
  </>
167
173
  );
@@ -179,7 +179,7 @@ function render_block_core_search( $attributes ) {
179
179
  if ( $is_expandable_searchfield ) {
180
180
  $aria_label_expanded = __( 'Submit Search' );
181
181
  $aria_label_collapsed = __( 'Expand search field' );
182
- $form_context = data_wp_context(
182
+ $form_context = wp_interactivity_data_wp_context(
183
183
  array(
184
184
  'isSearchInputVisible' => $open_by_default,
185
185
  'inputId' => $input_id,
@@ -12,6 +12,8 @@ $button-spacing-y: math.div($grid-unit-15, 2); // 6px
12
12
  svg {
13
13
  min-width: $grid-unit-30;
14
14
  min-height: $grid-unit-30;
15
+ width: 1.25em;
16
+ height: 1.25em;
15
17
  fill: currentColor;
16
18
  vertical-align: text-bottom;
17
19
  }
@@ -268,6 +268,14 @@ const SiteLogo = ( {
268
268
  </ResizableBox>
269
269
  );
270
270
 
271
+ // Support the previous location for the Site Icon settings. To be removed
272
+ // when the required WP core version for Gutenberg is >= 6.5.0.
273
+ const shouldUseNewUrl = ! window?.__experimentalUseCustomizerSiteLogoUrl;
274
+
275
+ const siteIconSettingsUrl = shouldUseNewUrl
276
+ ? siteUrl + '/wp-admin/options-general.php'
277
+ : siteUrl + '/wp-admin/customize.php?autofocus[section]=title_tagline';
278
+
271
279
  const syncSiteIconHelpText = createInterpolateElement(
272
280
  __(
273
281
  'Site Icons are what you see in browser tabs, bookmark bars, and within the WordPress mobile apps. To use a custom icon that is different from your site logo, use the <a>Site Icon settings</a>.'
@@ -276,10 +284,7 @@ const SiteLogo = ( {
276
284
  a: (
277
285
  // eslint-disable-next-line jsx-a11y/anchor-has-content
278
286
  <a
279
- href={
280
- siteUrl +
281
- '/wp-admin/customize.php?autofocus[section]=title_tagline'
282
- }
287
+ href={ siteIconSettingsUrl }
283
288
  target="_blank"
284
289
  rel="noopener noreferrer"
285
290
  />
@@ -331,7 +336,7 @@ const SiteLogo = ( {
331
336
  <>
332
337
  <ToggleControl
333
338
  __nextHasNoMarginBottom
334
- label={ __( 'Use as site icon' ) }
339
+ label={ __( 'Use as Site Icon' ) }
335
340
  onChange={ ( value ) => {
336
341
  setAttributes( { shouldSyncIcon: value } );
337
342
  setIcon( value ? logoId : undefined );
@@ -10,14 +10,21 @@ import { useState, useEffect, useCallback } from '@wordpress/element';
10
10
  import { usePrevious } from '@wordpress/compose';
11
11
  import { __ } from '@wordpress/i18n';
12
12
  import {
13
- RichText,
14
13
  BlockControls,
15
14
  __experimentalGetElementClassName,
15
+ privateApis as blockEditorPrivateApis,
16
16
  } from '@wordpress/block-editor';
17
17
  import { ToolbarButton } from '@wordpress/components';
18
18
  import { caption as captionIcon } from '@wordpress/icons';
19
19
  import { createBlock, getDefaultBlockName } from '@wordpress/blocks';
20
20
 
21
+ /**
22
+ * Internal dependencies
23
+ */
24
+ import { unlock } from '../lock-unlock';
25
+
26
+ const { PrivateRichText: RichText } = unlock( blockEditorPrivateApis );
27
+
21
28
  export function Caption( {
22
29
  key = 'caption',
23
30
  attributes,
@@ -28,6 +35,7 @@ export function Caption( {
28
35
  label = __( 'Caption text' ),
29
36
  showToolbarButton = true,
30
37
  className,
38
+ disableEditing,
31
39
  } ) {
32
40
  const caption = attributes[ key ];
33
41
  const prevCaption = usePrevious( caption );
@@ -101,6 +109,7 @@ export function Caption( {
101
109
  createBlock( getDefaultBlockName() )
102
110
  )
103
111
  }
112
+ disableEditing={ disableEditing }
104
113
  />
105
114
  ) }
106
115
  </>
@@ -0,0 +1,65 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import { getBlockType } from '@wordpress/blocks';
5
+
6
+ /**
7
+ * Transform the metadata attribute with only the values and bindings specified by each transform.
8
+ * Returns `undefined` if the input metadata is falsy.
9
+ *
10
+ * @param {Object} metadata Original metadata attribute from the block that is being transformed.
11
+ * @param {Object} newBlockName Name of the final block after the transformation.
12
+ * @param {Function} bindingsCallback Optional callback to transform the `bindings` property object.
13
+ * @return {Object|undefined} New metadata object only with the relevant properties.
14
+ */
15
+ export function getTransformedMetadata(
16
+ metadata,
17
+ newBlockName,
18
+ bindingsCallback
19
+ ) {
20
+ if ( ! metadata ) {
21
+ return;
22
+ }
23
+ const { supports } = getBlockType( newBlockName );
24
+ // Fixed until an opt-in mechanism is implemented.
25
+ const BLOCK_BINDINGS_SUPPORTED_BLOCKS = [
26
+ 'core/paragraph',
27
+ 'core/heading',
28
+ 'core/image',
29
+ 'core/button',
30
+ ];
31
+ // The metadata properties that should be preserved after the transform.
32
+ const transformSupportedProps = [];
33
+ // If it support bindings, and there is a transform bindings callback, add the `id` and `bindings` properties.
34
+ if (
35
+ BLOCK_BINDINGS_SUPPORTED_BLOCKS.includes( newBlockName ) &&
36
+ bindingsCallback
37
+ ) {
38
+ transformSupportedProps.push( 'id', 'bindings' );
39
+ }
40
+ // If it support block naming (true by default), add the `name` property.
41
+ if ( supports.renaming !== false ) {
42
+ transformSupportedProps.push( 'name' );
43
+ }
44
+
45
+ // Return early if no supported properties.
46
+ if ( ! transformSupportedProps.length ) {
47
+ return;
48
+ }
49
+
50
+ const newMetadata = Object.entries( metadata ).reduce(
51
+ ( obj, [ prop, value ] ) => {
52
+ // If prop is not supported, don't add it to the new metadata object.
53
+ if ( ! transformSupportedProps.includes( prop ) ) {
54
+ return obj;
55
+ }
56
+ obj[ prop ] =
57
+ prop === 'bindings' ? bindingsCallback( value ) : value;
58
+ return obj;
59
+ },
60
+ {}
61
+ );
62
+
63
+ // Return undefined if object is empty.
64
+ return Object.keys( newMetadata ).length ? newMetadata : undefined;
65
+ }
@@ -1,39 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = useCopy;
7
- var _compose = require("@wordpress/compose");
8
- var _blockEditor = require("@wordpress/block-editor");
9
- var _data = require("@wordpress/data");
10
- /**
11
- * WordPress dependencies
12
- */
13
-
14
- function useCopy(clientId) {
15
- const {
16
- getBlockRootClientId,
17
- getBlockName,
18
- getBlockAttributes
19
- } = (0, _data.useSelect)(_blockEditor.store);
20
- return (0, _compose.useRefEffect)(node => {
21
- function onCopy(event) {
22
- // The event propagates through all nested lists, so don't override
23
- // when copying nested list items.
24
- if (event.clipboardData.getData('__unstableWrapperBlockName')) {
25
- return;
26
- }
27
- const rootClientId = getBlockRootClientId(clientId);
28
- event.clipboardData.setData('__unstableWrapperBlockName', getBlockName(rootClientId));
29
- event.clipboardData.setData('__unstableWrapperBlockAttributes', JSON.stringify(getBlockAttributes(rootClientId)));
30
- }
31
- node.addEventListener('copy', onCopy);
32
- node.addEventListener('cut', onCopy);
33
- return () => {
34
- node.removeEventListener('copy', onCopy);
35
- node.removeEventListener('cut', onCopy);
36
- };
37
- }, []);
38
- }
39
- //# sourceMappingURL=use-copy.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["_compose","require","_blockEditor","_data","useCopy","clientId","getBlockRootClientId","getBlockName","getBlockAttributes","useSelect","blockEditorStore","useRefEffect","node","onCopy","event","clipboardData","getData","rootClientId","setData","JSON","stringify","addEventListener","removeEventListener"],"sources":["@wordpress/block-library/src/list-item/hooks/use-copy.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useRefEffect } from '@wordpress/compose';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport { useSelect } from '@wordpress/data';\n\nexport default function useCopy( clientId ) {\n\tconst { getBlockRootClientId, getBlockName, getBlockAttributes } =\n\t\tuseSelect( blockEditorStore );\n\n\treturn useRefEffect( ( node ) => {\n\t\tfunction onCopy( event ) {\n\t\t\t// The event propagates through all nested lists, so don't override\n\t\t\t// when copying nested list items.\n\t\t\tif ( event.clipboardData.getData( '__unstableWrapperBlockName' ) ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst rootClientId = getBlockRootClientId( clientId );\n\t\t\tevent.clipboardData.setData(\n\t\t\t\t'__unstableWrapperBlockName',\n\t\t\t\tgetBlockName( rootClientId )\n\t\t\t);\n\t\t\tevent.clipboardData.setData(\n\t\t\t\t'__unstableWrapperBlockAttributes',\n\t\t\t\tJSON.stringify( getBlockAttributes( rootClientId ) )\n\t\t\t);\n\t\t}\n\n\t\tnode.addEventListener( 'copy', onCopy );\n\t\tnode.addEventListener( 'cut', onCopy );\n\t\treturn () => {\n\t\t\tnode.removeEventListener( 'copy', onCopy );\n\t\t\tnode.removeEventListener( 'cut', onCopy );\n\t\t};\n\t}, [] );\n}\n"],"mappings":";;;;;;AAGA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AALA;AACA;AACA;;AAKe,SAASG,OAAOA,CAAEC,QAAQ,EAAG;EAC3C,MAAM;IAAEC,oBAAoB;IAAEC,YAAY;IAAEC;EAAmB,CAAC,GAC/D,IAAAC,eAAS,EAAEC,kBAAiB,CAAC;EAE9B,OAAO,IAAAC,qBAAY,EAAIC,IAAI,IAAM;IAChC,SAASC,MAAMA,CAAEC,KAAK,EAAG;MACxB;MACA;MACA,IAAKA,KAAK,CAACC,aAAa,CAACC,OAAO,CAAE,4BAA6B,CAAC,EAAG;QAClE;MACD;MAEA,MAAMC,YAAY,GAAGX,oBAAoB,CAAED,QAAS,CAAC;MACrDS,KAAK,CAACC,aAAa,CAACG,OAAO,CAC1B,4BAA4B,EAC5BX,YAAY,CAAEU,YAAa,CAC5B,CAAC;MACDH,KAAK,CAACC,aAAa,CAACG,OAAO,CAC1B,kCAAkC,EAClCC,IAAI,CAACC,SAAS,CAAEZ,kBAAkB,CAAES,YAAa,CAAE,CACpD,CAAC;IACF;IAEAL,IAAI,CAACS,gBAAgB,CAAE,MAAM,EAAER,MAAO,CAAC;IACvCD,IAAI,CAACS,gBAAgB,CAAE,KAAK,EAAER,MAAO,CAAC;IACtC,OAAO,MAAM;MACZD,IAAI,CAACU,mBAAmB,CAAE,MAAM,EAAET,MAAO,CAAC;MAC1CD,IAAI,CAACU,mBAAmB,CAAE,KAAK,EAAET,MAAO,CAAC;IAC1C,CAAC;EACF,CAAC,EAAE,EAAG,CAAC;AACR"}
@@ -1,32 +0,0 @@
1
- /**
2
- * WordPress dependencies
3
- */
4
- import { useRefEffect } from '@wordpress/compose';
5
- import { store as blockEditorStore } from '@wordpress/block-editor';
6
- import { useSelect } from '@wordpress/data';
7
- export default function useCopy(clientId) {
8
- const {
9
- getBlockRootClientId,
10
- getBlockName,
11
- getBlockAttributes
12
- } = useSelect(blockEditorStore);
13
- return useRefEffect(node => {
14
- function onCopy(event) {
15
- // The event propagates through all nested lists, so don't override
16
- // when copying nested list items.
17
- if (event.clipboardData.getData('__unstableWrapperBlockName')) {
18
- return;
19
- }
20
- const rootClientId = getBlockRootClientId(clientId);
21
- event.clipboardData.setData('__unstableWrapperBlockName', getBlockName(rootClientId));
22
- event.clipboardData.setData('__unstableWrapperBlockAttributes', JSON.stringify(getBlockAttributes(rootClientId)));
23
- }
24
- node.addEventListener('copy', onCopy);
25
- node.addEventListener('cut', onCopy);
26
- return () => {
27
- node.removeEventListener('copy', onCopy);
28
- node.removeEventListener('cut', onCopy);
29
- };
30
- }, []);
31
- }
32
- //# sourceMappingURL=use-copy.js.map