@wordpress/block-library 8.12.7 → 8.12.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 (70) hide show
  1. package/build/block/index.js +2 -1
  2. package/build/block/index.js.map +1 -1
  3. package/build/cover/deprecated.js +4 -2
  4. package/build/cover/deprecated.js.map +1 -1
  5. package/build/footnotes/edit.js +20 -1
  6. package/build/footnotes/edit.js.map +1 -1
  7. package/build/footnotes/format.js +19 -16
  8. package/build/footnotes/format.js.map +1 -1
  9. package/build/footnotes/index.js +0 -1
  10. package/build/footnotes/index.js.map +1 -1
  11. package/build/image/deprecated.js +453 -175
  12. package/build/image/deprecated.js.map +1 -1
  13. package/build/image/save.js +3 -1
  14. package/build/image/save.js.map +1 -1
  15. package/build/list/edit.js +4 -4
  16. package/build/list/edit.js.map +1 -1
  17. package/build/navigation/edit/index.js +1 -1
  18. package/build/navigation/edit/index.js.map +1 -1
  19. package/build/navigation/edit/use-convert-classic-menu-to-block-menu.js +1 -10
  20. package/build/navigation/edit/use-convert-classic-menu-to-block-menu.js.map +1 -1
  21. package/build/navigation-link/edit.js +10 -5
  22. package/build/navigation-link/edit.js.map +1 -1
  23. package/build/quote/transforms.js +8 -0
  24. package/build/quote/transforms.js.map +1 -1
  25. package/build-module/block/index.js +2 -1
  26. package/build-module/block/index.js.map +1 -1
  27. package/build-module/cover/deprecated.js +4 -2
  28. package/build-module/cover/deprecated.js.map +1 -1
  29. package/build-module/footnotes/edit.js +18 -2
  30. package/build-module/footnotes/edit.js.map +1 -1
  31. package/build-module/footnotes/format.js +19 -16
  32. package/build-module/footnotes/format.js.map +1 -1
  33. package/build-module/footnotes/index.js +0 -1
  34. package/build-module/footnotes/index.js.map +1 -1
  35. package/build-module/image/deprecated.js +454 -176
  36. package/build-module/image/deprecated.js.map +1 -1
  37. package/build-module/image/save.js +3 -1
  38. package/build-module/image/save.js.map +1 -1
  39. package/build-module/list/edit.js +4 -4
  40. package/build-module/list/edit.js.map +1 -1
  41. package/build-module/navigation/edit/index.js +1 -1
  42. package/build-module/navigation/edit/index.js.map +1 -1
  43. package/build-module/navigation/edit/use-convert-classic-menu-to-block-menu.js +1 -9
  44. package/build-module/navigation/edit/use-convert-classic-menu-to-block-menu.js.map +1 -1
  45. package/build-module/navigation-link/edit.js +10 -5
  46. package/build-module/navigation-link/edit.js.map +1 -1
  47. package/build-module/quote/transforms.js +8 -0
  48. package/build-module/quote/transforms.js.map +1 -1
  49. package/build-style/footnotes/style-rtl.css +4 -3
  50. package/build-style/footnotes/style.css +4 -3
  51. package/build-style/style-rtl.css +4 -3
  52. package/build-style/style.css +4 -3
  53. package/package.json +8 -8
  54. package/src/block/block.json +2 -1
  55. package/src/comment-template/index.php +5 -2
  56. package/src/cover/deprecated.js +2 -0
  57. package/src/footnotes/block.json +0 -1
  58. package/src/footnotes/edit.js +21 -2
  59. package/src/footnotes/format.js +22 -20
  60. package/src/footnotes/style.scss +6 -3
  61. package/src/image/deprecated.js +597 -320
  62. package/src/image/save.js +2 -0
  63. package/src/list/edit.js +6 -4
  64. package/src/navigation/edit/index.js +1 -1
  65. package/src/navigation/edit/use-convert-classic-menu-to-block-menu.js +1 -10
  66. package/src/navigation-link/edit.js +59 -45
  67. package/src/post-template/index.php +4 -2
  68. package/src/quote/test/__snapshots__/transforms.native.js.snap +10 -0
  69. package/src/quote/test/transforms.native.js +5 -1
  70. package/src/quote/transforms.js +13 -0
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 }
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
  </>
@@ -196,7 +196,7 @@ function Navigation( {
196
196
  convert: convertClassicMenu,
197
197
  status: classicMenuConversionStatus,
198
198
  error: classicMenuConversionError,
199
- } = useConvertClassicToBlockMenu( clientId );
199
+ } = useConvertClassicToBlockMenu( createNavigationMenu );
200
200
 
201
201
  const isConvertingClassicMenu =
202
202
  classicMenuConversionStatus === CLASSIC_MENU_CONVERSION_PENDING;
@@ -9,7 +9,6 @@ import { __, sprintf } from '@wordpress/i18n';
9
9
  /**
10
10
  * Internal dependencies
11
11
  */
12
- import useCreateNavigationMenu from './use-create-navigation-menu';
13
12
  import menuItemsToBlocks from '../menu-items-to-blocks';
14
13
 
15
14
  export const CLASSIC_MENU_CONVERSION_SUCCESS = 'success';
@@ -21,15 +20,7 @@ export const CLASSIC_MENU_CONVERSION_IDLE = 'idle';
21
20
  // do not import the same classic menu twice.
22
21
  let classicMenuBeingConvertedId = null;
23
22
 
24
- function useConvertClassicToBlockMenu( clientId ) {
25
- /*
26
- * The wp_navigation post is created as a draft so the changes on the frontend and
27
- * the site editor are not permanent without a save interaction done by the user.
28
- */
29
- const { create: createNavigationMenu } = useCreateNavigationMenu(
30
- clientId,
31
- 'draft'
32
- );
23
+ function useConvertClassicToBlockMenu( createNavigationMenu ) {
33
24
  const registry = useRegistry();
34
25
  const { editEntityRecord } = useDispatch( coreStore );
35
26
 
@@ -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' ) );
@@ -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' ],