@wordpress/block-library 8.12.6 → 8.12.8

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 (148) hide show
  1. package/build/archives/index.js +5 -1
  2. package/build/archives/index.js.map +1 -1
  3. package/build/audio/index.js +5 -1
  4. package/build/audio/index.js.map +1 -1
  5. package/build/categories/index.js +5 -1
  6. package/build/categories/index.js.map +1 -1
  7. package/build/code/index.js +5 -1
  8. package/build/code/index.js.map +1 -1
  9. package/build/details/index.js +5 -1
  10. package/build/details/index.js.map +1 -1
  11. package/build/footnotes/edit.js +20 -1
  12. package/build/footnotes/edit.js.map +1 -1
  13. package/build/footnotes/format.js +2 -7
  14. package/build/footnotes/format.js.map +1 -1
  15. package/build/footnotes/index.js +0 -1
  16. package/build/footnotes/index.js.map +1 -1
  17. package/build/gallery/index.js +3 -1
  18. package/build/gallery/index.js.map +1 -1
  19. package/build/heading/index.js +5 -1
  20. package/build/heading/index.js.map +1 -1
  21. package/build/heading/transforms.js +5 -1
  22. package/build/heading/transforms.js.map +1 -1
  23. package/build/image/deprecated.js +453 -175
  24. package/build/image/deprecated.js.map +1 -1
  25. package/build/image/image.js +1 -1
  26. package/build/image/image.js.map +1 -1
  27. package/build/image/save.js +3 -1
  28. package/build/image/save.js.map +1 -1
  29. package/build/list/edit.js +4 -4
  30. package/build/list/edit.js.map +1 -1
  31. package/build/list/index.js +5 -1
  32. package/build/list/index.js.map +1 -1
  33. package/build/list-item/utils.js +5 -1
  34. package/build/list-item/utils.js.map +1 -1
  35. package/build/navigation-link/edit.js +10 -5
  36. package/build/navigation-link/edit.js.map +1 -1
  37. package/build/post-time-to-read/index.js +5 -1
  38. package/build/post-time-to-read/index.js.map +1 -1
  39. package/build/quote/transforms.js +8 -0
  40. package/build/quote/transforms.js.map +1 -1
  41. package/build/site-logo/index.js +5 -1
  42. package/build/site-logo/index.js.map +1 -1
  43. package/build/site-tagline/index.js +5 -1
  44. package/build/site-tagline/index.js.map +1 -1
  45. package/build/site-title/index.js +5 -1
  46. package/build/site-title/index.js.map +1 -1
  47. package/build/social-links/index.js +3 -1
  48. package/build/social-links/index.js.map +1 -1
  49. package/build/table/index.js +5 -1
  50. package/build/table/index.js.map +1 -1
  51. package/build/verse/index.js +5 -1
  52. package/build/verse/index.js.map +1 -1
  53. package/build/video/deprecated.js +5 -1
  54. package/build/video/deprecated.js.map +1 -1
  55. package/build/video/index.js +5 -1
  56. package/build/video/index.js.map +1 -1
  57. package/build-module/archives/index.js +5 -1
  58. package/build-module/archives/index.js.map +1 -1
  59. package/build-module/audio/index.js +5 -1
  60. package/build-module/audio/index.js.map +1 -1
  61. package/build-module/categories/index.js +5 -1
  62. package/build-module/categories/index.js.map +1 -1
  63. package/build-module/code/index.js +5 -1
  64. package/build-module/code/index.js.map +1 -1
  65. package/build-module/details/index.js +5 -1
  66. package/build-module/details/index.js.map +1 -1
  67. package/build-module/footnotes/edit.js +18 -2
  68. package/build-module/footnotes/edit.js.map +1 -1
  69. package/build-module/footnotes/format.js +2 -7
  70. package/build-module/footnotes/format.js.map +1 -1
  71. package/build-module/footnotes/index.js +0 -1
  72. package/build-module/footnotes/index.js.map +1 -1
  73. package/build-module/gallery/index.js +3 -1
  74. package/build-module/gallery/index.js.map +1 -1
  75. package/build-module/heading/index.js +5 -1
  76. package/build-module/heading/index.js.map +1 -1
  77. package/build-module/heading/transforms.js +5 -1
  78. package/build-module/heading/transforms.js.map +1 -1
  79. package/build-module/image/deprecated.js +454 -176
  80. package/build-module/image/deprecated.js.map +1 -1
  81. package/build-module/image/image.js +1 -1
  82. package/build-module/image/image.js.map +1 -1
  83. package/build-module/image/save.js +3 -1
  84. package/build-module/image/save.js.map +1 -1
  85. package/build-module/list/edit.js +4 -4
  86. package/build-module/list/edit.js.map +1 -1
  87. package/build-module/list/index.js +5 -1
  88. package/build-module/list/index.js.map +1 -1
  89. package/build-module/list-item/utils.js +5 -1
  90. package/build-module/list-item/utils.js.map +1 -1
  91. package/build-module/navigation-link/edit.js +10 -5
  92. package/build-module/navigation-link/edit.js.map +1 -1
  93. package/build-module/post-time-to-read/index.js +5 -1
  94. package/build-module/post-time-to-read/index.js.map +1 -1
  95. package/build-module/quote/transforms.js +8 -0
  96. package/build-module/quote/transforms.js.map +1 -1
  97. package/build-module/site-logo/index.js +5 -1
  98. package/build-module/site-logo/index.js.map +1 -1
  99. package/build-module/site-tagline/index.js +5 -1
  100. package/build-module/site-tagline/index.js.map +1 -1
  101. package/build-module/site-title/index.js +5 -1
  102. package/build-module/site-title/index.js.map +1 -1
  103. package/build-module/social-links/index.js +3 -1
  104. package/build-module/social-links/index.js.map +1 -1
  105. package/build-module/table/index.js +5 -1
  106. package/build-module/table/index.js.map +1 -1
  107. package/build-module/verse/index.js +5 -1
  108. package/build-module/verse/index.js.map +1 -1
  109. package/build-module/video/deprecated.js +5 -1
  110. package/build-module/video/deprecated.js.map +1 -1
  111. package/build-module/video/index.js +5 -1
  112. package/build-module/video/index.js.map +1 -1
  113. package/build-style/footnotes/style-rtl.css +4 -3
  114. package/build-style/footnotes/style.css +4 -3
  115. package/build-style/style-rtl.css +4 -3
  116. package/build-style/style.css +4 -3
  117. package/package.json +12 -12
  118. package/src/archives/block.json +5 -1
  119. package/src/audio/block.json +5 -1
  120. package/src/categories/block.json +5 -1
  121. package/src/code/block.json +5 -1
  122. package/src/comment-template/index.php +5 -2
  123. package/src/details/block.json +5 -1
  124. package/src/footnotes/block.json +0 -1
  125. package/src/footnotes/edit.js +21 -2
  126. package/src/footnotes/format.js +2 -6
  127. package/src/footnotes/style.scss +6 -3
  128. package/src/gallery/block.json +3 -1
  129. package/src/heading/block.json +5 -1
  130. package/src/image/deprecated.js +597 -320
  131. package/src/image/image.js +2 -1
  132. package/src/image/save.js +2 -0
  133. package/src/list/block.json +5 -1
  134. package/src/list/edit.js +6 -4
  135. package/src/navigation-link/edit.js +59 -45
  136. package/src/post-template/index.php +4 -2
  137. package/src/post-time-to-read/block.json +5 -1
  138. package/src/post-title/index.php +6 -3
  139. package/src/quote/test/__snapshots__/transforms.native.js.snap +10 -0
  140. package/src/quote/test/transforms.native.js +5 -1
  141. package/src/quote/transforms.js +13 -0
  142. package/src/site-logo/block.json +5 -1
  143. package/src/site-tagline/block.json +5 -1
  144. package/src/site-title/block.json +5 -1
  145. package/src/social-links/block.json +3 -1
  146. package/src/table/block.json +5 -1
  147. package/src/verse/block.json +5 -1
  148. package/src/video/block.json +5 -1
@@ -607,7 +607,8 @@ export default function Image( {
607
607
  const ratio =
608
608
  ( aspectRatio && evalAspectRatio( aspectRatio ) ) ||
609
609
  ( width && height && width / height ) ||
610
- naturalWidth / naturalHeight;
610
+ naturalWidth / naturalHeight ||
611
+ 1;
611
612
 
612
613
  const currentWidth = ! width && height ? height * ratio : width;
613
614
  const currentHeight = ! height && width ? width / ratio : height;
package/src/image/save.js CHANGED
@@ -58,6 +58,8 @@ export default function save( { attributes } ) {
58
58
  ...borderProps.style,
59
59
  aspectRatio,
60
60
  objectFit: scale,
61
+ width,
62
+ height,
61
63
  } }
62
64
  width={ width }
63
65
  height={ height }
@@ -61,7 +61,11 @@
61
61
  },
62
62
  "spacing": {
63
63
  "margin": true,
64
- "padding": true
64
+ "padding": true,
65
+ "__experimentalDefaultControls": {
66
+ "margin": false,
67
+ "padding": false
68
+ }
65
69
  },
66
70
  "__unstablePasteTextInline": true,
67
71
  "__experimentalSelector": "ol,ul",
package/src/list/edit.js CHANGED
@@ -177,10 +177,12 @@ export default function Edit( { attributes, setAttributes, clientId, style } ) {
177
177
  { controls }
178
178
  { ordered && (
179
179
  <OrderedListSettings
180
- setAttributes={ setAttributes }
181
- ordered={ ordered }
182
- reversed={ reversed }
183
- start={ start }
180
+ { ...{
181
+ setAttributes,
182
+ reversed,
183
+ start,
184
+ type,
185
+ } }
184
186
  />
185
187
  ) }
186
188
  </>
@@ -181,6 +181,10 @@ export default function NavigationLinkEdit( {
181
181
  const itemLabelPlaceholder = __( 'Add label…' );
182
182
  const ref = useRef();
183
183
 
184
+ // Change the label using inspector causes rich text to change focus on firefox.
185
+ // This is a workaround to keep the focus on the label field when label filed is focused we don't render the rich text.
186
+ const [ isLabelFieldFocused, setIsLabelFieldFocused ] = useState( false );
187
+
184
188
  const {
185
189
  innerBlocks,
186
190
  isAtMaxNesting,
@@ -424,6 +428,8 @@ export default function NavigationLinkEdit( {
424
428
  } }
425
429
  label={ __( 'Label' ) }
426
430
  autoComplete="off"
431
+ onFocus={ () => setIsLabelFieldFocused( true ) }
432
+ onBlur={ () => setIsLabelFieldFocused( false ) }
427
433
  />
428
434
  <TextControl
429
435
  __nextHasNoMarginBottom
@@ -492,52 +498,56 @@ export default function NavigationLinkEdit( {
492
498
  </div>
493
499
  ) : (
494
500
  <>
495
- { ! isInvalid && ! isDraft && (
496
- <>
497
- <RichText
498
- ref={ ref }
499
- identifier="label"
500
- className="wp-block-navigation-item__label"
501
- value={ label }
502
- onChange={ ( labelValue ) =>
503
- setAttributes( {
504
- label: labelValue,
505
- } )
506
- }
507
- onMerge={ mergeBlocks }
508
- onReplace={ onReplace }
509
- __unstableOnSplitAtEnd={ () =>
510
- insertBlocksAfter(
511
- createBlock(
512
- 'core/navigation-link'
501
+ { ! isInvalid &&
502
+ ! isDraft &&
503
+ ! isLabelFieldFocused && (
504
+ <>
505
+ <RichText
506
+ ref={ ref }
507
+ identifier="label"
508
+ className="wp-block-navigation-item__label"
509
+ value={ label }
510
+ onChange={ ( labelValue ) =>
511
+ setAttributes( {
512
+ label: labelValue,
513
+ } )
514
+ }
515
+ onMerge={ mergeBlocks }
516
+ onReplace={ onReplace }
517
+ __unstableOnSplitAtEnd={ () =>
518
+ insertBlocksAfter(
519
+ createBlock(
520
+ 'core/navigation-link'
521
+ )
513
522
  )
514
- )
515
- }
516
- aria-label={ __(
517
- 'Navigation link text'
518
- ) }
519
- placeholder={ itemLabelPlaceholder }
520
- withoutInteractiveFormatting
521
- allowedFormats={ [
522
- 'core/bold',
523
- 'core/italic',
524
- 'core/image',
525
- 'core/strikethrough',
526
- ] }
527
- onClick={ () => {
528
- if ( ! url ) {
529
- setIsLinkOpen( true );
530
523
  }
531
- } }
532
- />
533
- { description && (
534
- <span className="wp-block-navigation-item__description">
535
- { description }
536
- </span>
537
- ) }
538
- </>
539
- ) }
540
- { ( isInvalid || isDraft ) && (
524
+ aria-label={ __(
525
+ 'Navigation link text'
526
+ ) }
527
+ placeholder={ itemLabelPlaceholder }
528
+ withoutInteractiveFormatting
529
+ allowedFormats={ [
530
+ 'core/bold',
531
+ 'core/italic',
532
+ 'core/image',
533
+ 'core/strikethrough',
534
+ ] }
535
+ onClick={ () => {
536
+ if ( ! url ) {
537
+ setIsLinkOpen( true );
538
+ }
539
+ } }
540
+ />
541
+ { description && (
542
+ <span className="wp-block-navigation-item__description">
543
+ { description }
544
+ </span>
545
+ ) }
546
+ </>
547
+ ) }
548
+ { ( isInvalid ||
549
+ isDraft ||
550
+ isLabelFieldFocused ) && (
541
551
  <div className="wp-block-navigation-link__placeholder-text wp-block-navigation-link__label">
542
552
  <Tooltip
543
553
  position="top center"
@@ -557,7 +567,11 @@ export default function NavigationLinkEdit( {
557
567
  // See `updateAttributes` for more details.
558
568
  `${ decodeEntities(
559
569
  label
560
- ) } ${ placeholderText }`.trim()
570
+ ) } ${
571
+ isInvalid || isDraft
572
+ ? placeholderText
573
+ : ''
574
+ }`.trim()
561
575
  }
562
576
  </span>
563
577
  <span className="wp-block-navigation-link__missing_text-tooltip">
@@ -97,11 +97,13 @@ function render_block_core_post_template( $attributes, $content, $block ) {
97
97
  $context['postId'] = $post_id;
98
98
  return $context;
99
99
  };
100
- add_filter( 'render_block_context', $filter_block_context );
100
+
101
+ // Use an early priority to so that other 'render_block_context' filters have access to the values.
102
+ add_filter( 'render_block_context', $filter_block_context, 1 );
101
103
  // Render the inner blocks of the Post Template block with `dynamic` set to `false` to prevent calling
102
104
  // `render_callback` and ensure that no wrapper markup is included.
103
105
  $block_content = ( new WP_Block( $block_instance ) )->render( array( 'dynamic' => false ) );
104
- remove_filter( 'render_block_context', $filter_block_context );
106
+ remove_filter( 'render_block_context', $filter_block_context, 1 );
105
107
 
106
108
  // Wrap the render inner blocks in a `li` element with the appropriate post classes.
107
109
  $post_classes = implode( ' ', get_post_class( 'wp-block-post' ) );
@@ -24,7 +24,11 @@
24
24
  "html": false,
25
25
  "spacing": {
26
26
  "margin": true,
27
- "padding": true
27
+ "padding": true,
28
+ "__experimentalDefaultControls": {
29
+ "margin": false,
30
+ "padding": false
31
+ }
28
32
  },
29
33
  "typography": {
30
34
  "fontSize": true,
@@ -19,8 +19,11 @@ function render_block_core_post_title( $attributes, $content, $block ) {
19
19
  return '';
20
20
  }
21
21
 
22
- $post = get_post( $block->context['postId'] );
23
- $title = get_the_title( $post );
22
+ /**
23
+ * The `$post` argument is intentionally omitted so that changes are reflected when previewing a post.
24
+ * See: https://github.com/WordPress/gutenberg/pull/37622#issuecomment-1000932816.
25
+ */
26
+ $title = get_the_title();
24
27
 
25
28
  if ( ! $title ) {
26
29
  return '';
@@ -33,7 +36,7 @@ function render_block_core_post_title( $attributes, $content, $block ) {
33
36
 
34
37
  if ( isset( $attributes['isLink'] ) && $attributes['isLink'] ) {
35
38
  $rel = ! empty( $attributes['rel'] ) ? 'rel="' . esc_attr( $attributes['rel'] ) . '"' : '';
36
- $title = sprintf( '<a href="%1$s" target="%2$s" %3$s>%4$s</a>', get_the_permalink( $post ), esc_attr( $attributes['linkTarget'] ), $rel, $title );
39
+ $title = sprintf( '<a href="%1$s" target="%2$s" %3$s>%4$s</a>', get_the_permalink( $block->context['postId'] ), esc_attr( $attributes['linkTarget'] ), $rel, $title );
37
40
  }
38
41
 
39
42
  $classes = array();
@@ -22,6 +22,16 @@ exports[`Quote block transforms to Group block 1`] = `
22
22
  <!-- /wp:group -->"
23
23
  `;
24
24
 
25
+ exports[`Quote block transforms to Paragraph block 1`] = `
26
+ "<!-- wp:paragraph -->
27
+ <p>"This will make running your own blog a viable alternative again."</p>
28
+ <!-- /wp:paragraph -->
29
+
30
+ <!-- wp:paragraph -->
31
+ <p>— <a href="https://twitter.com/azumbrunnen_/status/1019347243084800005">Adrian Zumbrunnen</a></p>
32
+ <!-- /wp:paragraph -->"
33
+ `;
34
+
25
35
  exports[`Quote block transforms to Pullquote block 1`] = `
26
36
  "<!-- wp:pullquote -->
27
37
  <figure class="wp-block-pullquote"><blockquote><p>"This will make running your own blog a viable alternative again."</p><cite>— <a href="https://twitter.com/azumbrunnen_/status/1019347243084800005">Adrian Zumbrunnen</a></cite></blockquote></figure>
@@ -21,7 +21,11 @@ const initialHtml = `
21
21
  <!-- /wp:quote -->`;
22
22
 
23
23
  const transformsWithInnerBlocks = [ 'Columns', 'Group' ];
24
- const blockTransforms = [ 'Pullquote', ...transformsWithInnerBlocks ];
24
+ const blockTransforms = [
25
+ 'Pullquote',
26
+ 'Paragraph',
27
+ ...transformsWithInnerBlocks,
28
+ ];
25
29
 
26
30
  setupCoreBlocks();
27
31
 
@@ -109,6 +109,19 @@ const transforms = {
109
109
  } );
110
110
  },
111
111
  },
112
+ {
113
+ type: 'block',
114
+ blocks: [ 'core/paragraph' ],
115
+ transform: ( { citation }, innerBlocks ) =>
116
+ citation
117
+ ? [
118
+ ...innerBlocks,
119
+ createBlock( 'core/paragraph', {
120
+ content: citation,
121
+ } ),
122
+ ]
123
+ : innerBlocks,
124
+ },
112
125
  {
113
126
  type: 'block',
114
127
  blocks: [ 'core/group' ],
@@ -40,7 +40,11 @@
40
40
  },
41
41
  "spacing": {
42
42
  "margin": true,
43
- "padding": true
43
+ "padding": true,
44
+ "__experimentalDefaultControls": {
45
+ "margin": false,
46
+ "padding": false
47
+ }
44
48
  }
45
49
  },
46
50
  "styles": [
@@ -25,7 +25,11 @@
25
25
  },
26
26
  "spacing": {
27
27
  "margin": true,
28
- "padding": true
28
+ "padding": true,
29
+ "__experimentalDefaultControls": {
30
+ "margin": false,
31
+ "padding": false
32
+ }
29
33
  },
30
34
  "typography": {
31
35
  "fontSize": true,
@@ -40,7 +40,11 @@
40
40
  },
41
41
  "spacing": {
42
42
  "padding": true,
43
- "margin": true
43
+ "margin": true,
44
+ "__experimentalDefaultControls": {
45
+ "margin": false,
46
+ "padding": false
47
+ }
44
48
  },
45
49
  "typography": {
46
50
  "fontSize": true,
@@ -73,7 +73,9 @@
73
73
  "padding": true,
74
74
  "units": [ "px", "em", "rem", "vh", "vw" ],
75
75
  "__experimentalDefaultControls": {
76
- "blockGap": true
76
+ "blockGap": true,
77
+ "margin": true,
78
+ "padding": false
77
79
  }
78
80
  }
79
81
  },
@@ -166,7 +166,11 @@
166
166
  },
167
167
  "spacing": {
168
168
  "margin": true,
169
- "padding": true
169
+ "padding": true,
170
+ "__experimentalDefaultControls": {
171
+ "margin": false,
172
+ "padding": false
173
+ }
170
174
  },
171
175
  "typography": {
172
176
  "fontSize": true,
@@ -46,7 +46,11 @@
46
46
  },
47
47
  "spacing": {
48
48
  "margin": true,
49
- "padding": true
49
+ "padding": true,
50
+ "__experimentalDefaultControls": {
51
+ "margin": false,
52
+ "padding": false
53
+ }
50
54
  },
51
55
  "__experimentalBorder": {
52
56
  "radius": true,
@@ -83,7 +83,11 @@
83
83
  "align": true,
84
84
  "spacing": {
85
85
  "margin": true,
86
- "padding": true
86
+ "padding": true,
87
+ "__experimentalDefaultControls": {
88
+ "margin": false,
89
+ "padding": false
90
+ }
87
91
  }
88
92
  },
89
93
  "editorStyle": "wp-block-video-editor",