@wordpress/block-editor 13.0.0 → 13.1.0

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 (218) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/build/components/block-actions/index.js +4 -6
  3. package/build/components/block-actions/index.js.map +1 -1
  4. package/build/components/block-draggable/index.js +1 -1
  5. package/build/components/block-draggable/index.js.map +1 -1
  6. package/build/components/block-list/block.js +2 -2
  7. package/build/components/block-list/block.js.map +1 -1
  8. package/build/components/block-list/block.native.js +2 -2
  9. package/build/components/block-list/block.native.js.map +1 -1
  10. package/build/components/block-list/use-in-between-inserter.js +3 -1
  11. package/build/components/block-list/use-in-between-inserter.js.map +1 -1
  12. package/build/components/block-lock/use-block-lock.js +2 -4
  13. package/build/components/block-lock/use-block-lock.js.map +1 -1
  14. package/build/components/block-mover/index.js +1 -1
  15. package/build/components/block-mover/index.js.map +1 -1
  16. package/build/components/block-mover/index.native.js +1 -1
  17. package/build/components/block-mover/index.native.js.map +1 -1
  18. package/build/components/block-settings-menu/block-settings-dropdown.js +1 -1
  19. package/build/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
  20. package/build/components/block-switcher/block-variation-transformations.js +1 -3
  21. package/build/components/block-switcher/block-variation-transformations.js.map +1 -1
  22. package/build/components/block-switcher/index.js +13 -6
  23. package/build/components/block-switcher/index.js.map +1 -1
  24. package/build/components/block-toolbar/index.js +6 -10
  25. package/build/components/block-toolbar/index.js.map +1 -1
  26. package/build/components/block-tools/block-selection-button.js +2 -2
  27. package/build/components/block-tools/block-selection-button.js.map +1 -1
  28. package/build/components/button-block-appender/index.js +4 -1
  29. package/build/components/button-block-appender/index.js.map +1 -1
  30. package/build/components/date-format-picker/index.js +18 -10
  31. package/build/components/date-format-picker/index.js.map +1 -1
  32. package/build/components/global-styles/background-panel.js +3 -3
  33. package/build/components/global-styles/background-panel.js.map +1 -1
  34. package/build/components/global-styles/hooks.js +2 -2
  35. package/build/components/global-styles/hooks.js.map +1 -1
  36. package/build/components/global-styles/use-global-styles-output.js +14 -1
  37. package/build/components/global-styles/use-global-styles-output.js.map +1 -1
  38. package/build/components/inserter/block-types-tab.js +3 -3
  39. package/build/components/inserter/block-types-tab.js.map +1 -1
  40. package/build/components/inserter/block-types-tab.native.js +1 -1
  41. package/build/components/inserter/block-types-tab.native.js.map +1 -1
  42. package/build/components/inserter/hooks/use-block-types-state.js +3 -2
  43. package/build/components/inserter/hooks/use-block-types-state.js.map +1 -1
  44. package/build/components/link-control/link-preview.js +13 -1
  45. package/build/components/link-control/link-preview.js.map +1 -1
  46. package/build/components/link-control/search-input.js +1 -1
  47. package/build/components/link-control/search-input.js.map +1 -1
  48. package/build/components/list-view/block.js +7 -6
  49. package/build/components/list-view/block.js.map +1 -1
  50. package/build/components/list-view/branch.js +3 -1
  51. package/build/components/list-view/branch.js.map +1 -1
  52. package/build/components/list-view/use-clipboard-handler.js +1 -1
  53. package/build/components/list-view/use-clipboard-handler.js.map +1 -1
  54. package/build/components/provider/use-block-sync.js +1 -7
  55. package/build/components/provider/use-block-sync.js.map +1 -1
  56. package/build/components/rich-text/index.native.js +4 -0
  57. package/build/components/rich-text/index.native.js.map +1 -1
  58. package/build/components/rich-text/native/index.native.js +6 -4
  59. package/build/components/rich-text/native/index.native.js.map +1 -1
  60. package/build/components/spacing-sizes-control/hooks/use-spacing-sizes.js +9 -12
  61. package/build/components/spacing-sizes-control/hooks/use-spacing-sizes.js.map +1 -1
  62. package/build/components/use-block-commands/index.js +3 -3
  63. package/build/components/use-block-commands/index.js.map +1 -1
  64. package/build/components/writing-flow/use-clipboard-handler.js +22 -3
  65. package/build/components/writing-flow/use-clipboard-handler.js.map +1 -1
  66. package/build/hooks/block-bindings.js +19 -16
  67. package/build/hooks/block-bindings.js.map +1 -1
  68. package/build/hooks/block-style-variation.js +2 -2
  69. package/build/hooks/block-style-variation.js.map +1 -1
  70. package/build/hooks/use-bindings-attributes.js +7 -2
  71. package/build/hooks/use-bindings-attributes.js.map +1 -1
  72. package/build/private-apis.js +3 -1
  73. package/build/private-apis.js.map +1 -1
  74. package/build/store/actions.js +4 -4
  75. package/build/store/actions.js.map +1 -1
  76. package/build/store/private-actions.js +1 -36
  77. package/build/store/private-actions.js.map +1 -1
  78. package/build/store/selectors.js +19 -20
  79. package/build/store/selectors.js.map +1 -1
  80. package/build-module/components/block-actions/index.js +4 -6
  81. package/build-module/components/block-actions/index.js.map +1 -1
  82. package/build-module/components/block-draggable/index.js +1 -1
  83. package/build-module/components/block-draggable/index.js.map +1 -1
  84. package/build-module/components/block-list/block.js +2 -2
  85. package/build-module/components/block-list/block.js.map +1 -1
  86. package/build-module/components/block-list/block.native.js +2 -2
  87. package/build-module/components/block-list/block.native.js.map +1 -1
  88. package/build-module/components/block-list/use-in-between-inserter.js +3 -1
  89. package/build-module/components/block-list/use-in-between-inserter.js.map +1 -1
  90. package/build-module/components/block-lock/use-block-lock.js +2 -4
  91. package/build-module/components/block-lock/use-block-lock.js.map +1 -1
  92. package/build-module/components/block-mover/index.js +1 -1
  93. package/build-module/components/block-mover/index.js.map +1 -1
  94. package/build-module/components/block-mover/index.native.js +1 -1
  95. package/build-module/components/block-mover/index.native.js.map +1 -1
  96. package/build-module/components/block-settings-menu/block-settings-dropdown.js +1 -1
  97. package/build-module/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
  98. package/build-module/components/block-switcher/block-variation-transformations.js +1 -3
  99. package/build-module/components/block-switcher/block-variation-transformations.js.map +1 -1
  100. package/build-module/components/block-switcher/index.js +15 -8
  101. package/build-module/components/block-switcher/index.js.map +1 -1
  102. package/build-module/components/block-toolbar/index.js +7 -10
  103. package/build-module/components/block-toolbar/index.js.map +1 -1
  104. package/build-module/components/block-tools/block-selection-button.js +2 -2
  105. package/build-module/components/block-tools/block-selection-button.js.map +1 -1
  106. package/build-module/components/button-block-appender/index.js +4 -1
  107. package/build-module/components/button-block-appender/index.js.map +1 -1
  108. package/build-module/components/date-format-picker/index.js +19 -11
  109. package/build-module/components/date-format-picker/index.js.map +1 -1
  110. package/build-module/components/global-styles/background-panel.js +4 -4
  111. package/build-module/components/global-styles/background-panel.js.map +1 -1
  112. package/build-module/components/global-styles/hooks.js +2 -2
  113. package/build-module/components/global-styles/hooks.js.map +1 -1
  114. package/build-module/components/global-styles/use-global-styles-output.js +14 -1
  115. package/build-module/components/global-styles/use-global-styles-output.js.map +1 -1
  116. package/build-module/components/inserter/block-types-tab.js +3 -3
  117. package/build-module/components/inserter/block-types-tab.js.map +1 -1
  118. package/build-module/components/inserter/block-types-tab.native.js +1 -1
  119. package/build-module/components/inserter/block-types-tab.native.js.map +1 -1
  120. package/build-module/components/inserter/hooks/use-block-types-state.js +4 -3
  121. package/build-module/components/inserter/hooks/use-block-types-state.js.map +1 -1
  122. package/build-module/components/link-control/link-preview.js +15 -1
  123. package/build-module/components/link-control/link-preview.js.map +1 -1
  124. package/build-module/components/link-control/search-input.js +1 -1
  125. package/build-module/components/link-control/search-input.js.map +1 -1
  126. package/build-module/components/list-view/block.js +7 -6
  127. package/build-module/components/list-view/block.js.map +1 -1
  128. package/build-module/components/list-view/branch.js +3 -1
  129. package/build-module/components/list-view/branch.js.map +1 -1
  130. package/build-module/components/list-view/use-clipboard-handler.js +1 -1
  131. package/build-module/components/list-view/use-clipboard-handler.js.map +1 -1
  132. package/build-module/components/provider/use-block-sync.js +1 -7
  133. package/build-module/components/provider/use-block-sync.js.map +1 -1
  134. package/build-module/components/rich-text/index.native.js +4 -0
  135. package/build-module/components/rich-text/index.native.js.map +1 -1
  136. package/build-module/components/rich-text/native/index.native.js +6 -4
  137. package/build-module/components/rich-text/native/index.native.js.map +1 -1
  138. package/build-module/components/spacing-sizes-control/hooks/use-spacing-sizes.js +9 -12
  139. package/build-module/components/spacing-sizes-control/hooks/use-spacing-sizes.js.map +1 -1
  140. package/build-module/components/use-block-commands/index.js +3 -3
  141. package/build-module/components/use-block-commands/index.js.map +1 -1
  142. package/build-module/components/writing-flow/use-clipboard-handler.js +23 -4
  143. package/build-module/components/writing-flow/use-clipboard-handler.js.map +1 -1
  144. package/build-module/hooks/block-bindings.js +20 -17
  145. package/build-module/hooks/block-bindings.js.map +1 -1
  146. package/build-module/hooks/block-style-variation.js +2 -2
  147. package/build-module/hooks/block-style-variation.js.map +1 -1
  148. package/build-module/hooks/use-bindings-attributes.js +7 -2
  149. package/build-module/hooks/use-bindings-attributes.js.map +1 -1
  150. package/build-module/private-apis.js +3 -1
  151. package/build-module/private-apis.js.map +1 -1
  152. package/build-module/store/actions.js +4 -4
  153. package/build-module/store/actions.js.map +1 -1
  154. package/build-module/store/private-actions.js +1 -35
  155. package/build-module/store/private-actions.js.map +1 -1
  156. package/build-module/store/selectors.js +19 -20
  157. package/build-module/store/selectors.js.map +1 -1
  158. package/build-style/content-rtl.css +1 -1
  159. package/build-style/content.css +1 -1
  160. package/build-style/style-rtl.css +13 -17
  161. package/build-style/style.css +13 -17
  162. package/package.json +31 -31
  163. package/src/components/block-actions/index.js +3 -7
  164. package/src/components/block-canvas/style.scss +2 -2
  165. package/src/components/block-draggable/index.js +1 -1
  166. package/src/components/block-list/block.js +2 -2
  167. package/src/components/block-list/block.native.js +2 -2
  168. package/src/components/block-list/use-in-between-inserter.js +3 -1
  169. package/src/components/block-lock/use-block-lock.js +2 -4
  170. package/src/components/block-mover/index.js +1 -1
  171. package/src/components/block-mover/index.native.js +1 -1
  172. package/src/components/block-settings-menu/block-settings-dropdown.js +1 -1
  173. package/src/components/block-switcher/block-variation-transformations.js +4 -9
  174. package/src/components/block-switcher/index.js +27 -12
  175. package/src/components/block-switcher/style.scss +5 -0
  176. package/src/components/block-toolbar/index.js +7 -9
  177. package/src/components/block-toolbar/style.scss +9 -6
  178. package/src/components/block-tools/block-selection-button.js +2 -2
  179. package/src/components/block-variation-picker/content.scss +1 -1
  180. package/src/components/button-block-appender/index.js +2 -0
  181. package/src/components/date-format-picker/index.js +25 -13
  182. package/src/components/global-styles/background-panel.js +13 -4
  183. package/src/components/global-styles/hooks.js +2 -4
  184. package/src/components/global-styles/use-global-styles-output.js +24 -4
  185. package/src/components/inserter/block-types-tab.js +0 -1
  186. package/src/components/inserter/block-types-tab.native.js +2 -1
  187. package/src/components/inserter/hooks/use-block-types-state.js +10 -5
  188. package/src/components/inserter/style.scss +4 -0
  189. package/src/components/link-control/link-preview.js +19 -1
  190. package/src/components/link-control/search-input.js +1 -1
  191. package/src/components/list-view/block.js +7 -7
  192. package/src/components/list-view/branch.js +5 -1
  193. package/src/components/list-view/use-clipboard-handler.js +1 -6
  194. package/src/components/provider/use-block-sync.js +0 -6
  195. package/src/components/rich-text/index.native.js +4 -0
  196. package/src/components/rich-text/native/index.native.js +3 -1
  197. package/src/components/spacing-sizes-control/hooks/use-spacing-sizes.js +7 -4
  198. package/src/components/use-block-commands/index.js +3 -4
  199. package/src/components/writing-flow/use-clipboard-handler.js +29 -7
  200. package/src/hooks/block-bindings.js +28 -22
  201. package/src/hooks/block-style-variation.js +2 -2
  202. package/src/hooks/use-bindings-attributes.js +11 -1
  203. package/src/private-apis.js +2 -0
  204. package/src/store/actions.js +4 -10
  205. package/src/store/private-actions.js +1 -34
  206. package/src/store/selectors.js +22 -27
  207. package/src/style.scss +0 -1
  208. package/build/components/block-bindings-toolbar-indicator/index.js +0 -106
  209. package/build/components/block-bindings-toolbar-indicator/index.js.map +0 -1
  210. package/build/store/undo-ignore.js +0 -11
  211. package/build/store/undo-ignore.js.map +0 -1
  212. package/build-module/components/block-bindings-toolbar-indicator/index.js +0 -99
  213. package/build-module/components/block-bindings-toolbar-indicator/index.js.map +0 -1
  214. package/build-module/store/undo-ignore.js +0 -5
  215. package/build-module/store/undo-ignore.js.map +0 -1
  216. package/src/components/block-bindings-toolbar-indicator/index.js +0 -135
  217. package/src/components/block-bindings-toolbar-indicator/style.scss +0 -12
  218. package/src/store/undo-ignore.js +0 -4
@@ -2,7 +2,7 @@
2
2
  * WordPress dependencies
3
3
  */
4
4
  import { _x, __ } from '@wordpress/i18n';
5
- import { dateI18n } from '@wordpress/date';
5
+ import { dateI18n, humanTimeDiff } from '@wordpress/date';
6
6
  import { useState, createInterpolateElement } from '@wordpress/element';
7
7
  import {
8
8
  TextControl,
@@ -13,11 +13,15 @@ import {
13
13
  __experimentalVStack as VStack,
14
14
  } from '@wordpress/components';
15
15
 
16
- // So that we can illustrate the different formats in the dropdown properly,
17
- // show a date that has a day greater than 12 and a month with more than three
18
- // letters. Here we're using 2022-01-25 which is when WordPress 5.9 was
19
- // released.
20
- const EXAMPLE_DATE = new Date( 2022, 0, 25 );
16
+ // So that we illustrate the different formats in the dropdown properly, show a date that is
17
+ // somwhat recent, has a day greater than 12, and a month with more than three letters.
18
+ const exampleDate = new Date();
19
+ exampleDate.setDate( 20 );
20
+ exampleDate.setMonth( exampleDate.getMonth() - 3 );
21
+ if ( exampleDate.getMonth() === 4 ) {
22
+ // May has three letters, so use March.
23
+ exampleDate.setMonth( 3 );
24
+ }
21
25
 
22
26
  /**
23
27
  * The `DateFormatPicker` component renders controls that let the user choose a
@@ -54,7 +58,7 @@ export default function DateFormatPicker( {
54
58
  label={ __( 'Default format' ) }
55
59
  help={ `${ __( 'Example:' ) } ${ dateI18n(
56
60
  defaultFormat,
57
- EXAMPLE_DATE
61
+ exampleDate
58
62
  ) }` }
59
63
  checked={ ! format }
60
64
  onChange={ ( checked ) =>
@@ -95,13 +99,19 @@ function NonDefaultControls( { format, onChange } ) {
95
99
  ] ),
96
100
  ];
97
101
 
98
- const suggestedOptions = suggestedFormats.map(
99
- ( suggestedFormat, index ) => ( {
102
+ const suggestedOptions = [
103
+ ...suggestedFormats.map( ( suggestedFormat, index ) => ( {
100
104
  key: `suggested-${ index }`,
101
- name: dateI18n( suggestedFormat, EXAMPLE_DATE ),
105
+ name: dateI18n( suggestedFormat, exampleDate ),
102
106
  format: suggestedFormat,
103
- } )
104
- );
107
+ } ) ),
108
+ {
109
+ key: 'human-diff',
110
+ name: humanTimeDiff( exampleDate ),
111
+ format: 'human-diff',
112
+ },
113
+ ];
114
+
105
115
  const customOption = {
106
116
  key: 'custom',
107
117
  name: __( 'Custom' ),
@@ -111,7 +121,9 @@ function NonDefaultControls( { format, onChange } ) {
111
121
  };
112
122
 
113
123
  const [ isCustom, setIsCustom ] = useState(
114
- () => !! format && ! suggestedFormats.includes( format )
124
+ () =>
125
+ !! format &&
126
+ ! suggestedOptions.some( ( option ) => option.format === format )
115
127
  );
116
128
 
117
129
  return (
@@ -23,7 +23,7 @@ import {
23
23
  __experimentalHStack as HStack,
24
24
  __experimentalTruncate as Truncate,
25
25
  } from '@wordpress/components';
26
- import { __, sprintf } from '@wordpress/i18n';
26
+ import { __, _x, sprintf } from '@wordpress/i18n';
27
27
  import { store as noticesStore } from '@wordpress/notices';
28
28
  import { getFilename } from '@wordpress/url';
29
29
  import { useCallback, Platform, useRef } from '@wordpress/element';
@@ -544,17 +544,26 @@ function BackgroundSizeToolsPanelItem( {
544
544
  <ToggleGroupControlOption
545
545
  key="cover"
546
546
  value="cover"
547
- label={ __( 'Cover' ) }
547
+ label={ _x(
548
+ 'Cover',
549
+ 'Size option for background image control'
550
+ ) }
548
551
  />
549
552
  <ToggleGroupControlOption
550
553
  key="contain"
551
554
  value="contain"
552
- label={ __( 'Contain' ) }
555
+ label={ _x(
556
+ 'Contain',
557
+ 'Size option for background image control'
558
+ ) }
553
559
  />
554
560
  <ToggleGroupControlOption
555
561
  key="tile"
556
562
  value="auto"
557
- label={ __( 'Tile' ) }
563
+ label={ _x(
564
+ 'Tile',
565
+ 'Size option for background image control'
566
+ ) }
558
567
  />
559
568
  </ToggleGroupControl>
560
569
  <HStack justify="flex-start" spacing={ 2 } as="span">
@@ -89,10 +89,7 @@ export const useGlobalStylesReset = () => {
89
89
  const canReset = !! config && ! fastDeepEqual( config, EMPTY_CONFIG );
90
90
  return [
91
91
  canReset,
92
- useCallback(
93
- () => setUserConfig( () => EMPTY_CONFIG ),
94
- [ setUserConfig ]
95
- ),
92
+ useCallback( () => setUserConfig( EMPTY_CONFIG ), [ setUserConfig ] ),
96
93
  ];
97
94
  };
98
95
 
@@ -299,6 +296,7 @@ export function useSettingsForBlockElement(
299
296
  'fontStyle',
300
297
  'fontWeight',
301
298
  'letterSpacing',
299
+ 'textAlign',
302
300
  'textTransform',
303
301
  'textDecoration',
304
302
  'writingMode',
@@ -651,7 +651,9 @@ export const getNodesWithStyles = ( tree, blockSelectors ) => {
651
651
  ( [ variationName, variation ] ) => {
652
652
  variations[ variationName ] =
653
653
  pickStyleKeys( variation );
654
-
654
+ if ( variation?.css ) {
655
+ variations[ variationName ].css = variation.css;
656
+ }
655
657
  const variationSelector =
656
658
  blockSelectors[ blockName ]
657
659
  .styleVariationSelectors?.[ variationName ];
@@ -697,6 +699,14 @@ export const getNodesWithStyles = ( tree, blockSelectors ) => {
697
699
  .featureSelectors
698
700
  );
699
701
 
702
+ const variationBlockStyleNodes =
703
+ pickStyleKeys( variationBlockStyles );
704
+
705
+ if ( variationBlockStyles?.css ) {
706
+ variationBlockStyleNodes.css =
707
+ variationBlockStyles.css;
708
+ }
709
+
700
710
  nodes.push( {
701
711
  selector: variationBlockSelector,
702
712
  duotoneSelector: variationDuotoneSelector,
@@ -707,9 +717,7 @@ export const getNodesWithStyles = ( tree, blockSelectors ) => {
707
717
  hasLayoutSupport:
708
718
  blockSelectors[ variationBlockName ]
709
719
  .hasLayoutSupport,
710
- styles: pickStyleKeys(
711
- variationBlockStyles
712
- ),
720
+ styles: variationBlockStyleNodes,
713
721
  } );
714
722
 
715
723
  // Process element styles for the inner blocks
@@ -995,6 +1003,12 @@ export const toStyles = (
995
1003
  ';'
996
1004
  ) };}`;
997
1005
  }
1006
+ if ( styles?.css ) {
1007
+ ruleset += processCSSNesting(
1008
+ styles.css,
1009
+ `:root :where(${ selector })`
1010
+ );
1011
+ }
998
1012
 
999
1013
  if ( styleVariationSelectors ) {
1000
1014
  Object.entries( styleVariationSelectors ).forEach(
@@ -1041,6 +1055,12 @@ export const toStyles = (
1041
1055
  ';'
1042
1056
  ) };}`;
1043
1057
  }
1058
+ if ( styleVariations?.css ) {
1059
+ ruleset += processCSSNesting(
1060
+ styleVariations.css,
1061
+ `:root :where(${ styleVariationSelector })`
1062
+ );
1063
+ }
1044
1064
  }
1045
1065
  }
1046
1066
  );
@@ -207,7 +207,6 @@ export function BlockTypesTab(
207
207
  showMostUsedBlocks={ showMostUsedBlocks }
208
208
  className="block-editor-inserter__insertable-blocks-at-selection"
209
209
  />
210
- <hr />
211
210
  </>
212
211
  ) }
213
212
  <BlockTypesTabPanel
@@ -18,7 +18,8 @@ const getBlockNamespace = ( item ) => item.name.split( '/' )[ 0 ];
18
18
  function BlockTypesTab( { onSelect, rootClientId, listProps } ) {
19
19
  const [ rawBlockTypes, , collections ] = useBlockTypesState(
20
20
  rootClientId,
21
- onSelect
21
+ onSelect,
22
+ true
22
23
  );
23
24
  const clipboardBlock = useClipboardBlock( rootClientId );
24
25
  const filteredBlockTypes = filterInserterItems( rawBlockTypes );
@@ -8,7 +8,7 @@ import {
8
8
  parse,
9
9
  } from '@wordpress/blocks';
10
10
  import { useSelect } from '@wordpress/data';
11
- import { useCallback } from '@wordpress/element';
11
+ import { useCallback, useMemo } from '@wordpress/element';
12
12
 
13
13
  /**
14
14
  * Internal dependencies
@@ -25,13 +25,18 @@ import { withRootClientIdOptionKey } from '../../../store/utils';
25
25
  * @return {Array} Returns the block types state. (block types, categories, collections, onSelect handler)
26
26
  */
27
27
  const useBlockTypesState = ( rootClientId, onInsert, isQuick ) => {
28
+ const options = useMemo(
29
+ () => ( { [ withRootClientIdOptionKey ]: ! isQuick } ),
30
+ [ isQuick ]
31
+ );
28
32
  const [ items ] = useSelect(
29
33
  ( select ) => [
30
- select( blockEditorStore ).getInserterItems( rootClientId, {
31
- [ withRootClientIdOptionKey ]: ! isQuick,
32
- } ),
34
+ select( blockEditorStore ).getInserterItems(
35
+ rootClientId,
36
+ options
37
+ ),
33
38
  ],
34
- [ rootClientId, isQuick ]
39
+ [ rootClientId, options ]
35
40
  );
36
41
 
37
42
  const [ categories, collections ] = useSelect( ( select ) => {
@@ -253,6 +253,10 @@ $block-inserter-tabs-height: 44px;
253
253
  }
254
254
  }
255
255
 
256
+ .block-editor-inserter__insertable-blocks-at-selection {
257
+ border-bottom: $border-width solid $gray-200;
258
+ }
259
+
256
260
  .block-editor-inserter__media-tabs-container,
257
261
  .block-editor-inserter__block-patterns-tabs-container {
258
262
  padding: $grid-unit-20;
@@ -27,6 +27,20 @@ import { ViewerSlot } from './viewer-slot';
27
27
 
28
28
  import useRichUrlData from './use-rich-url-data';
29
29
 
30
+ /**
31
+ * Filters the title for display. Removes the protocol and www prefix.
32
+ *
33
+ * @param {string} title The title to be filtered.
34
+ *
35
+ * @return {string} The filtered title.
36
+ */
37
+ function filterTitleForDisplay( title ) {
38
+ // Derived from `filterURLForDisplay` in `@wordpress/url`.
39
+ return title
40
+ .replace( /^[a-z\-.\+]+[0-9]*:(\/\/)?/i, '' )
41
+ .replace( /^www\./i, '' );
42
+ }
43
+
30
44
  export default function LinkPreview( {
31
45
  value,
32
46
  onEditClick,
@@ -59,6 +73,9 @@ export default function LinkPreview( {
59
73
  ! isEmptyURL &&
60
74
  stripHTML( richData?.title || value?.title || displayURL );
61
75
 
76
+ const isUrlRedundant =
77
+ ! value?.url || filterTitleForDisplay( displayTitle ) === displayURL;
78
+
62
79
  let icon;
63
80
 
64
81
  if ( richData?.icon ) {
@@ -112,7 +129,7 @@ export default function LinkPreview( {
112
129
  { displayTitle }
113
130
  </Truncate>
114
131
  </ExternalLink>
115
- { value?.url && displayTitle !== displayURL && (
132
+ { ! isUrlRedundant && (
116
133
  <span className="block-editor-link-control__search-item-info">
117
134
  <Truncate numberOfLines={ 1 }>
118
135
  { displayURL }
@@ -149,6 +166,7 @@ export default function LinkPreview( {
149
166
  isEmptyURL || showIconLabels ? '' : ': ' + value.url
150
167
  ) }
151
168
  ref={ ref }
169
+ __experimentalIsFocusable
152
170
  disabled={ isEmptyURL }
153
171
  size="compact"
154
172
  />
@@ -125,7 +125,7 @@ const LinkControlSearchInput = forwardRef(
125
125
  className={ className }
126
126
  value={ value }
127
127
  onChange={ onInputChange }
128
- placeholder={ placeholder ?? __( 'Search or type url' ) }
128
+ placeholder={ placeholder ?? __( 'Search or type URL' ) }
129
129
  __experimentalRenderSuggestions={
130
130
  showSuggestions ? handleRenderSuggestions : null
131
131
  }
@@ -181,6 +181,12 @@ function ListViewBlock( {
181
181
  return;
182
182
  }
183
183
 
184
+ // Do not handle events if it comes from modals;
185
+ // retain the default behavior for these keys.
186
+ if ( event.target.closest( '[role=dialog]' ) ) {
187
+ return;
188
+ }
189
+
184
190
  const isDeleteKey = [ BACKSPACE, DELETE ].includes( event.keyCode );
185
191
 
186
192
  // If multiple blocks are selected, deselect all blocks when the user
@@ -196,12 +202,6 @@ function ListViewBlock( {
196
202
  isDeleteKey ||
197
203
  isMatch( 'core/block-editor/remove', event )
198
204
  ) {
199
- // Do not handle single-key block deletion shortcuts when events come from modals;
200
- // retain the default behavior for these keys.
201
- if ( isDeleteKey && event.target.closest( '[role=dialog]' ) ) {
202
- return;
203
- }
204
-
205
205
  const {
206
206
  blocksToUpdate: blocksToDelete,
207
207
  firstBlockClientId,
@@ -210,7 +210,7 @@ function ListViewBlock( {
210
210
  } = getBlocksToUpdate();
211
211
 
212
212
  // Don't update the selection if the blocks cannot be deleted.
213
- if ( ! canRemoveBlocks( blocksToDelete, firstBlockRootClientId ) ) {
213
+ if ( ! canRemoveBlocks( blocksToDelete ) ) {
214
214
  return;
215
215
  }
216
216
 
@@ -194,10 +194,14 @@ function ListViewBranch( props ) {
194
194
  // This prevents the entire tree from being rendered when a branch is
195
195
  // selected, or a user selects all blocks, while still enabling scroll
196
196
  // into view behavior when selecting a block or opening the list view.
197
+ // The first and last blocks of the list are always rendered, to ensure
198
+ // that Home and End keys work as expected.
197
199
  const showBlock =
198
200
  isDragged ||
199
201
  blockInView ||
200
- ( isSelected && clientId === selectedClientIds[ 0 ] );
202
+ ( isSelected && clientId === selectedClientIds[ 0 ] ) ||
203
+ index === 0 ||
204
+ index === blockCount - 1;
201
205
  return (
202
206
  <AsyncModeProvider key={ clientId } value={ ! isSelected }>
203
207
  { showBlock && (
@@ -112,12 +112,7 @@ export default function useClipboardHandler( { selectBlock } ) {
112
112
 
113
113
  if ( event.type === 'cut' ) {
114
114
  // Don't update the selection if the blocks cannot be deleted.
115
- if (
116
- ! canRemoveBlocks(
117
- selectedBlockClientIds,
118
- firstBlockRootClientId
119
- )
120
- ) {
115
+ if ( ! canRemoveBlocks( selectedBlockClientIds ) ) {
121
116
  return;
122
117
  }
123
118
 
@@ -9,7 +9,6 @@ import { cloneBlock } from '@wordpress/blocks';
9
9
  * Internal dependencies
10
10
  */
11
11
  import { store as blockEditorStore } from '../../store';
12
- import { undoIgnoreBlocks } from '../../store/undo-ignore';
13
12
 
14
13
  const noop = () => {};
15
14
 
@@ -274,10 +273,6 @@ export default function useBlockSync( {
274
273
  const updateParent = isPersistent
275
274
  ? onChangeRef.current
276
275
  : onInputRef.current;
277
- const undoIgnore = undoIgnoreBlocks.has( blocks );
278
- if ( undoIgnore ) {
279
- undoIgnoreBlocks.delete( blocks );
280
- }
281
276
  updateParent( blocks, {
282
277
  selection: {
283
278
  selectionStart: getSelectionStart(),
@@ -285,7 +280,6 @@ export default function useBlockSync( {
285
280
  initialPosition:
286
281
  getSelectedBlocksInitialCaretPosition(),
287
282
  },
288
- undoIgnore,
289
283
  } );
290
284
  }
291
285
  previousAreBlocksDifferent = areBlocksDifferent;
@@ -80,6 +80,7 @@ export function RichTextWrapper(
80
80
  unstableOnFocus,
81
81
  __unstableAllowPrefixTransformations,
82
82
  // Native props.
83
+ __unstableUseSplitSelection,
83
84
  __unstableMobileNoFocusOnMount,
84
85
  deleteEnter,
85
86
  placeholderTextColor,
@@ -178,6 +179,7 @@ export function RichTextWrapper(
178
179
  exitFormattedText,
179
180
  selectionChange,
180
181
  __unstableMarkAutomaticChange,
182
+ __unstableSplitSelection,
181
183
  clearSelectedBlock,
182
184
  } = useDispatch( blockEditorStore );
183
185
  const adjustedAllowedFormats = getAllowedFormats( {
@@ -345,6 +347,8 @@ export function RichTextWrapper(
345
347
  }
346
348
  } else if ( canSplit ) {
347
349
  splitValue( value );
350
+ } else if ( __unstableUseSplitSelection ) {
351
+ __unstableSplitSelection();
348
352
  } else if ( canSplitAtEnd ) {
349
353
  onSplitAtEnd();
350
354
  } else if (
@@ -424,7 +424,9 @@ export class RichText extends Component {
424
424
  return;
425
425
  }
426
426
 
427
- onDelete( { isReverse, value } );
427
+ if ( onDelete ) {
428
+ onDelete( { isReverse, value } );
429
+ }
428
430
 
429
431
  event.preventDefault();
430
432
  this.lastAztecEventType = 'input';
@@ -42,7 +42,12 @@ export default function useSpacingSizes() {
42
42
  ...customSizes,
43
43
  ...themeSizes,
44
44
  ...defaultSizes,
45
- ].sort( ( a, b ) => compare( a.slug, b.slug ) );
45
+ ];
46
+
47
+ // Using numeric slugs opts-in to sorting by slug.
48
+ if ( sizes.every( ( { slug } ) => /^[0-9]/.test( slug ) ) ) {
49
+ sizes.sort( ( a, b ) => compare( a.slug, b.slug ) );
50
+ }
46
51
 
47
52
  return sizes.length > RANGE_CONTROL_MAX_SIZE
48
53
  ? [
@@ -53,8 +58,6 @@ export default function useSpacingSizes() {
53
58
  },
54
59
  ...sizes,
55
60
  ]
56
- : // See https://github.com/WordPress/gutenberg/pull/44247 for reasoning
57
- // to use the index as the name in the range control.
58
- sizes.map( ( { slug, size }, i ) => ( { name: i, slug, size } ) );
61
+ : sizes;
59
62
  }, [ customSizes, themeSizes, defaultSizes ] );
60
63
  }
@@ -65,7 +65,7 @@ export const useTransformCommands = () => {
65
65
  selectedBlocks,
66
66
  rootClientId
67
67
  ),
68
- canRemove: canRemoveBlocks( selectedBlockClientIds, rootClientId ),
68
+ canRemove: canRemoveBlocks( selectedBlockClientIds ),
69
69
  invalidSelection: false,
70
70
  };
71
71
  }, [] );
@@ -150,8 +150,7 @@ const useActionsCommands = () => {
150
150
  const rootClientId = getBlockRootClientId( clientIds[ 0 ] );
151
151
 
152
152
  const canMove =
153
- canMoveBlocks( clientIds, rootClientId ) &&
154
- getBlockCount( rootClientId ) !== 1;
153
+ canMoveBlocks( clientIds ) && getBlockCount( rootClientId ) !== 1;
155
154
 
156
155
  const commands = [];
157
156
 
@@ -260,7 +259,7 @@ const useQuickActionsCommands = () => {
260
259
  canInsertBlockType( block.name, rootClientId )
261
260
  );
262
261
  } );
263
- const canRemove = canRemoveBlocks( clientIds, rootClientId );
262
+ const canRemove = canRemoveBlocks( clientIds );
264
263
 
265
264
  const commands = [];
266
265
 
@@ -6,6 +6,7 @@ import {
6
6
  findTransform,
7
7
  getBlockTransforms,
8
8
  hasBlockSupport,
9
+ switchToBlockType,
9
10
  } from '@wordpress/blocks';
10
11
  import {
11
12
  documentHasSelection,
@@ -208,15 +209,36 @@ export default function useClipboardHandler() {
208
209
  firstSelectedClientId
209
210
  );
210
211
 
211
- if (
212
- ! blocks.every( ( block ) =>
213
- canInsertBlockType( block.name, rootClientId )
214
- )
215
- ) {
216
- return;
212
+ const newBlocks = [];
213
+
214
+ for ( const block of blocks ) {
215
+ if ( canInsertBlockType( block.name, rootClientId ) ) {
216
+ newBlocks.push( block );
217
+ } else {
218
+ // If a block cannot be inserted in a root block, try
219
+ // converting it to that root block type and insert the
220
+ // inner blocks.
221
+ // Example: paragraphs cannot be inserted into a list,
222
+ // so convert the paragraphs to a list for list items.
223
+ const rootBlockName = getBlockName( rootClientId );
224
+ const switchedBlocks =
225
+ block.name !== rootBlockName
226
+ ? switchToBlockType( block, rootBlockName )
227
+ : [ block ];
228
+
229
+ if ( ! switchedBlocks ) {
230
+ return;
231
+ }
232
+
233
+ for ( const switchedBlock of switchedBlocks ) {
234
+ for ( const innerBlock of switchedBlock.innerBlocks ) {
235
+ newBlocks.push( innerBlock );
236
+ }
237
+ }
238
+ }
217
239
  }
218
240
 
219
- __unstableSplitSelection( blocks );
241
+ __unstableSplitSelection( newBlocks );
220
242
  event.preventDefault();
221
243
  }
222
244
  }
@@ -4,6 +4,7 @@
4
4
  import { __ } from '@wordpress/i18n';
5
5
  import { store as blocksStore } from '@wordpress/blocks';
6
6
  import {
7
+ BaseControl,
7
8
  PanelBody,
8
9
  __experimentalHStack as HStack,
9
10
  __experimentalItemGroup as ItemGroup,
@@ -54,30 +55,35 @@ export const BlockBindingsPanel = ( { name, metadata } ) => {
54
55
  return (
55
56
  <InspectorControls>
56
57
  <PanelBody
57
- title={ __( 'Bindings' ) }
58
+ title={ __( 'Attributes' ) }
58
59
  className="components-panel__block-bindings-panel"
59
60
  >
60
- <ItemGroup isBordered isSeparated size="large">
61
- { Object.keys( filteredBindings ).map( ( key ) => {
62
- return (
63
- <Item key={ key }>
64
- <HStack>
65
- <span>{ key }</span>
66
- <span className="components-item__block-bindings-source">
67
- { sources[
68
- filteredBindings[ key ].source
69
- ]
70
- ? sources[
71
- filteredBindings[ key ]
72
- .source
73
- ].label
74
- : filteredBindings[ key ].source }
75
- </span>
76
- </HStack>
77
- </Item>
78
- );
79
- } ) }
80
- </ItemGroup>
61
+ <BaseControl
62
+ help={ __( 'Attributes connected to various sources.' ) }
63
+ >
64
+ <ItemGroup isBordered isSeparated size="large">
65
+ { Object.keys( filteredBindings ).map( ( key ) => {
66
+ return (
67
+ <Item key={ key }>
68
+ <HStack>
69
+ <span>{ key }</span>
70
+ <span className="components-item__block-bindings-source">
71
+ { sources[
72
+ filteredBindings[ key ].source
73
+ ]
74
+ ? sources[
75
+ filteredBindings[ key ]
76
+ .source
77
+ ].label
78
+ : filteredBindings[ key ]
79
+ .source }
80
+ </span>
81
+ </HStack>
82
+ </Item>
83
+ );
84
+ } ) }
85
+ </ItemGroup>
86
+ </BaseControl>
81
87
  </PanelBody>
82
88
  </InspectorControls>
83
89
  );
@@ -43,7 +43,7 @@ function getVariationNameFromClass( className, registeredStyles = [] ) {
43
43
  return null;
44
44
  }
45
45
 
46
- function useBlockSyleVariation( name, variation, clientId ) {
46
+ function useBlockStyleVariation( name, variation, clientId ) {
47
47
  // Prefer global styles data in GlobalStylesContext, which are available
48
48
  // if in the site editor. Otherwise fall back to whatever is in the
49
49
  // editor settings and available in the post editor.
@@ -96,7 +96,7 @@ function useBlockProps( { name, className, clientId } ) {
96
96
  const variation = getVariationNameFromClass( className, registeredStyles );
97
97
  const variationClass = `is-style-${ variation }-${ clientId }`;
98
98
 
99
- const { settings, styles } = useBlockSyleVariation(
99
+ const { settings, styles } = useBlockStyleVariation(
100
100
  name,
101
101
  variation,
102
102
  clientId
@@ -97,6 +97,9 @@ export const withBlockBindingSupport = createHigherOrderComponent(
97
97
  unlock( select( blocksStore ) ).getAllBlockBindingsSources()
98
98
  );
99
99
  const { name, clientId, context } = props;
100
+ const hasPatternOverridesDefaultBinding =
101
+ props.attributes.metadata?.bindings?.[ DEFAULT_ATTRIBUTE ]
102
+ ?.source === 'core/pattern-overrides';
100
103
  const bindings = useMemo(
101
104
  () =>
102
105
  replacePatternOverrideDefaultBindings(
@@ -213,7 +216,13 @@ export const withBlockBindingSupport = createHigherOrderComponent(
213
216
  }
214
217
  }
215
218
 
216
- if ( Object.keys( keptAttributes ).length ) {
219
+ // Only apply normal attribute updates to blocks
220
+ // that have partial bindings. Currently this is
221
+ // only skipped for pattern overrides sources.
222
+ if (
223
+ ! hasPatternOverridesDefaultBinding &&
224
+ Object.keys( keptAttributes ).length
225
+ ) {
217
226
  setAttributes( keptAttributes );
218
227
  }
219
228
  } );
@@ -226,6 +235,7 @@ export const withBlockBindingSupport = createHigherOrderComponent(
226
235
  context,
227
236
  setAttributes,
228
237
  sources,
238
+ hasPatternOverridesDefaultBinding,
229
239
  ]
230
240
  );
231
241