@wordpress/block-editor 13.0.1 → 13.0.3

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 (168) hide show
  1. package/build/components/block-actions/index.js +4 -6
  2. package/build/components/block-actions/index.js.map +1 -1
  3. package/build/components/block-draggable/index.js +1 -1
  4. package/build/components/block-draggable/index.js.map +1 -1
  5. package/build/components/block-list/block.js +2 -2
  6. package/build/components/block-list/block.js.map +1 -1
  7. package/build/components/block-list/block.native.js +2 -2
  8. package/build/components/block-list/block.native.js.map +1 -1
  9. package/build/components/block-list/use-in-between-inserter.js +3 -1
  10. package/build/components/block-list/use-in-between-inserter.js.map +1 -1
  11. package/build/components/block-lock/use-block-lock.js +2 -4
  12. package/build/components/block-lock/use-block-lock.js.map +1 -1
  13. package/build/components/block-mover/index.js +1 -1
  14. package/build/components/block-mover/index.js.map +1 -1
  15. package/build/components/block-mover/index.native.js +1 -1
  16. package/build/components/block-mover/index.native.js.map +1 -1
  17. package/build/components/block-settings-menu/block-settings-dropdown.js +1 -1
  18. package/build/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
  19. package/build/components/block-switcher/block-variation-transformations.js +1 -3
  20. package/build/components/block-switcher/block-variation-transformations.js.map +1 -1
  21. package/build/components/block-switcher/index.js +13 -6
  22. package/build/components/block-switcher/index.js.map +1 -1
  23. package/build/components/block-toolbar/index.js +6 -10
  24. package/build/components/block-toolbar/index.js.map +1 -1
  25. package/build/components/block-toolbar/shuffle.js +3 -1
  26. package/build/components/block-toolbar/shuffle.js.map +1 -1
  27. package/build/components/block-tools/block-selection-button.js +2 -2
  28. package/build/components/block-tools/block-selection-button.js.map +1 -1
  29. package/build/components/global-styles/hooks.js +1 -1
  30. package/build/components/global-styles/hooks.js.map +1 -1
  31. package/build/components/global-styles/use-global-styles-output.js +18 -4
  32. package/build/components/global-styles/use-global-styles-output.js.map +1 -1
  33. package/build/components/image-editor/aspect-ratio-dropdown.js +0 -1
  34. package/build/components/image-editor/aspect-ratio-dropdown.js.map +1 -1
  35. package/build/components/list-view/block.js +7 -6
  36. package/build/components/list-view/block.js.map +1 -1
  37. package/build/components/list-view/branch.js +3 -1
  38. package/build/components/list-view/branch.js.map +1 -1
  39. package/build/components/list-view/use-clipboard-handler.js +1 -1
  40. package/build/components/list-view/use-clipboard-handler.js.map +1 -1
  41. package/build/components/spacing-sizes-control/hooks/use-spacing-sizes.js +4 -4
  42. package/build/components/spacing-sizes-control/hooks/use-spacing-sizes.js.map +1 -1
  43. package/build/components/use-block-commands/index.js +3 -3
  44. package/build/components/use-block-commands/index.js.map +1 -1
  45. package/build/hooks/block-bindings.js +19 -16
  46. package/build/hooks/block-bindings.js.map +1 -1
  47. package/build/hooks/block-style-variation.js +26 -7
  48. package/build/hooks/block-style-variation.js.map +1 -1
  49. package/build/hooks/use-bindings-attributes.js +7 -2
  50. package/build/hooks/use-bindings-attributes.js.map +1 -1
  51. package/build/hooks/utils.js +3 -2
  52. package/build/hooks/utils.js.map +1 -1
  53. package/build/lock-unlock.js +1 -1
  54. package/build/lock-unlock.js.map +1 -1
  55. package/build/private-apis.js +3 -1
  56. package/build/private-apis.js.map +1 -1
  57. package/build/store/actions.js +20 -4
  58. package/build/store/actions.js.map +1 -1
  59. package/build/store/private-actions.js +1 -2
  60. package/build/store/private-actions.js.map +1 -1
  61. package/build/store/selectors.js +17 -19
  62. package/build/store/selectors.js.map +1 -1
  63. package/build-module/components/block-actions/index.js +4 -6
  64. package/build-module/components/block-actions/index.js.map +1 -1
  65. package/build-module/components/block-draggable/index.js +1 -1
  66. package/build-module/components/block-draggable/index.js.map +1 -1
  67. package/build-module/components/block-list/block.js +2 -2
  68. package/build-module/components/block-list/block.js.map +1 -1
  69. package/build-module/components/block-list/block.native.js +2 -2
  70. package/build-module/components/block-list/block.native.js.map +1 -1
  71. package/build-module/components/block-list/use-in-between-inserter.js +3 -1
  72. package/build-module/components/block-list/use-in-between-inserter.js.map +1 -1
  73. package/build-module/components/block-lock/use-block-lock.js +2 -4
  74. package/build-module/components/block-lock/use-block-lock.js.map +1 -1
  75. package/build-module/components/block-mover/index.js +1 -1
  76. package/build-module/components/block-mover/index.js.map +1 -1
  77. package/build-module/components/block-mover/index.native.js +1 -1
  78. package/build-module/components/block-mover/index.native.js.map +1 -1
  79. package/build-module/components/block-settings-menu/block-settings-dropdown.js +1 -1
  80. package/build-module/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
  81. package/build-module/components/block-switcher/block-variation-transformations.js +1 -3
  82. package/build-module/components/block-switcher/block-variation-transformations.js.map +1 -1
  83. package/build-module/components/block-switcher/index.js +15 -8
  84. package/build-module/components/block-switcher/index.js.map +1 -1
  85. package/build-module/components/block-toolbar/index.js +7 -10
  86. package/build-module/components/block-toolbar/index.js.map +1 -1
  87. package/build-module/components/block-toolbar/shuffle.js +3 -1
  88. package/build-module/components/block-toolbar/shuffle.js.map +1 -1
  89. package/build-module/components/block-tools/block-selection-button.js +2 -2
  90. package/build-module/components/block-tools/block-selection-button.js.map +1 -1
  91. package/build-module/components/global-styles/hooks.js +1 -1
  92. package/build-module/components/global-styles/hooks.js.map +1 -1
  93. package/build-module/components/global-styles/use-global-styles-output.js +18 -4
  94. package/build-module/components/global-styles/use-global-styles-output.js.map +1 -1
  95. package/build-module/components/image-editor/aspect-ratio-dropdown.js +0 -1
  96. package/build-module/components/image-editor/aspect-ratio-dropdown.js.map +1 -1
  97. package/build-module/components/list-view/block.js +7 -6
  98. package/build-module/components/list-view/block.js.map +1 -1
  99. package/build-module/components/list-view/branch.js +3 -1
  100. package/build-module/components/list-view/branch.js.map +1 -1
  101. package/build-module/components/list-view/use-clipboard-handler.js +1 -1
  102. package/build-module/components/list-view/use-clipboard-handler.js.map +1 -1
  103. package/build-module/components/spacing-sizes-control/hooks/use-spacing-sizes.js +4 -4
  104. package/build-module/components/spacing-sizes-control/hooks/use-spacing-sizes.js.map +1 -1
  105. package/build-module/components/use-block-commands/index.js +3 -3
  106. package/build-module/components/use-block-commands/index.js.map +1 -1
  107. package/build-module/hooks/block-bindings.js +20 -17
  108. package/build-module/hooks/block-bindings.js.map +1 -1
  109. package/build-module/hooks/block-style-variation.js +25 -7
  110. package/build-module/hooks/block-style-variation.js.map +1 -1
  111. package/build-module/hooks/use-bindings-attributes.js +7 -2
  112. package/build-module/hooks/use-bindings-attributes.js.map +1 -1
  113. package/build-module/hooks/utils.js +3 -2
  114. package/build-module/hooks/utils.js.map +1 -1
  115. package/build-module/lock-unlock.js +1 -1
  116. package/build-module/lock-unlock.js.map +1 -1
  117. package/build-module/private-apis.js +3 -1
  118. package/build-module/private-apis.js.map +1 -1
  119. package/build-module/store/actions.js +20 -4
  120. package/build-module/store/actions.js.map +1 -1
  121. package/build-module/store/private-actions.js +1 -2
  122. package/build-module/store/private-actions.js.map +1 -1
  123. package/build-module/store/selectors.js +17 -19
  124. package/build-module/store/selectors.js.map +1 -1
  125. package/build-style/style-rtl.css +8 -17
  126. package/build-style/style.css +8 -17
  127. package/package.json +13 -13
  128. package/src/components/block-actions/index.js +3 -7
  129. package/src/components/block-draggable/index.js +1 -1
  130. package/src/components/block-list/block.js +2 -2
  131. package/src/components/block-list/block.native.js +2 -2
  132. package/src/components/block-list/use-in-between-inserter.js +3 -1
  133. package/src/components/block-lock/use-block-lock.js +2 -4
  134. package/src/components/block-mover/index.js +1 -1
  135. package/src/components/block-mover/index.native.js +1 -1
  136. package/src/components/block-settings-menu/block-settings-dropdown.js +1 -1
  137. package/src/components/block-switcher/block-variation-transformations.js +4 -9
  138. package/src/components/block-switcher/index.js +27 -12
  139. package/src/components/block-switcher/style.scss +5 -0
  140. package/src/components/block-toolbar/index.js +7 -9
  141. package/src/components/block-toolbar/shuffle.js +3 -1
  142. package/src/components/block-toolbar/style.scss +9 -6
  143. package/src/components/block-tools/block-selection-button.js +2 -2
  144. package/src/components/global-styles/hooks.js +1 -4
  145. package/src/components/global-styles/test/use-global-styles-output.js +38 -3
  146. package/src/components/global-styles/use-global-styles-output.js +28 -7
  147. package/src/components/image-editor/aspect-ratio-dropdown.js +0 -1
  148. package/src/components/list-view/block.js +7 -7
  149. package/src/components/list-view/branch.js +5 -1
  150. package/src/components/list-view/use-clipboard-handler.js +1 -6
  151. package/src/components/spacing-sizes-control/hooks/use-spacing-sizes.js +2 -9
  152. package/src/components/use-block-commands/index.js +3 -4
  153. package/src/hooks/block-bindings.js +28 -22
  154. package/src/hooks/block-style-variation.js +24 -6
  155. package/src/hooks/use-bindings-attributes.js +11 -1
  156. package/src/hooks/utils.js +3 -1
  157. package/src/lock-unlock.js +1 -1
  158. package/src/private-apis.js +2 -0
  159. package/src/store/actions.js +24 -10
  160. package/src/store/private-actions.js +1 -5
  161. package/src/store/selectors.js +19 -26
  162. package/src/style.scss +0 -1
  163. package/build/components/block-bindings-toolbar-indicator/index.js +0 -106
  164. package/build/components/block-bindings-toolbar-indicator/index.js.map +0 -1
  165. package/build-module/components/block-bindings-toolbar-indicator/index.js +0 -99
  166. package/build-module/components/block-bindings-toolbar-indicator/index.js.map +0 -1
  167. package/src/components/block-bindings-toolbar-indicator/index.js +0 -137
  168. package/src/components/block-bindings-toolbar-indicator/style.scss +0 -12
@@ -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
@@ -873,6 +881,7 @@ export const toStyles = (
873
881
  marginReset: true,
874
882
  presets: true,
875
883
  rootPadding: true,
884
+ variationStyles: false,
876
885
  ...styleOptions,
877
886
  };
878
887
  const nodesWithStyles = getNodesWithStyles( tree, blockSelectors );
@@ -915,8 +924,8 @@ export const toStyles = (
915
924
  ruleset += `padding-right: 0; padding-left: 0; padding-top: var(--wp--style--root--padding-top); padding-bottom: var(--wp--style--root--padding-bottom) }
916
925
  .has-global-padding { padding-right: var(--wp--style--root--padding-right); padding-left: var(--wp--style--root--padding-left); }
917
926
  .has-global-padding > .alignfull { margin-right: calc(var(--wp--style--root--padding-right) * -1); margin-left: calc(var(--wp--style--root--padding-left) * -1); }
918
- .has-global-padding :where(.has-global-padding:not(.wp-block-block, .alignfull, .alignwide)) { padding-right: 0; padding-left: 0; }
919
- .has-global-padding :where(.has-global-padding:not(.wp-block-block, .alignfull, .alignwide)) > .alignfull { margin-left: 0; margin-right: 0;
927
+ .has-global-padding :where(:not(.alignfull.is-layout-flow) > .has-global-padding:not(.wp-block-block, .alignfull, .alignwide)) { padding-right: 0; padding-left: 0; }
928
+ .has-global-padding :where(:not(.alignfull.is-layout-flow) > .has-global-padding:not(.wp-block-block, .alignfull, .alignwide)) > .alignfull { margin-left: 0; margin-right: 0;
920
929
  `;
921
930
  }
922
931
 
@@ -995,8 +1004,14 @@ export const toStyles = (
995
1004
  ';'
996
1005
  ) };}`;
997
1006
  }
1007
+ if ( styles?.css ) {
1008
+ ruleset += processCSSNesting(
1009
+ styles.css,
1010
+ `:root :where(${ selector })`
1011
+ );
1012
+ }
998
1013
 
999
- if ( styleVariationSelectors ) {
1014
+ if ( options.variationStyles && styleVariationSelectors ) {
1000
1015
  Object.entries( styleVariationSelectors ).forEach(
1001
1016
  ( [ styleVariationName, styleVariationSelector ] ) => {
1002
1017
  const styleVariations =
@@ -1041,6 +1056,12 @@ export const toStyles = (
1041
1056
  ';'
1042
1057
  ) };}`;
1043
1058
  }
1059
+ if ( styleVariations?.css ) {
1060
+ ruleset += processCSSNesting(
1061
+ styleVariations.css,
1062
+ `:root :where(${ styleVariationSelector })`
1063
+ );
1064
+ }
1044
1065
  }
1045
1066
  }
1046
1067
  );
@@ -78,7 +78,6 @@ export default function AspectRatioDropdown( { toggleProps } ) {
78
78
  label={ __( 'Aspect Ratio' ) }
79
79
  popoverProps={ POPOVER_PROPS }
80
80
  toggleProps={ toggleProps }
81
- className="wp-block-image__aspect-ratio"
82
81
  >
83
82
  { ( { onClose } ) => (
84
83
  <>
@@ -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
 
@@ -44,15 +44,8 @@ export default function useSpacingSizes() {
44
44
  ...defaultSizes,
45
45
  ];
46
46
 
47
- // Only sort if more than one origin has presets defined in order to
48
- // preserve order for themes that don't include default presets and
49
- // want a custom order.
50
- if (
51
- ( customSizes.length && 1 ) +
52
- ( themeSizes.length && 1 ) +
53
- ( defaultSizes.length && 1 ) >
54
- 1
55
- ) {
47
+ // Using numeric slugs opts-in to sorting by slug.
48
+ if ( sizes.every( ( { slug } ) => /^[0-9]/.test( slug ) ) ) {
56
49
  sizes.sort( ( a, b ) => compare( a.slug, b.slug ) );
57
50
  }
58
51
 
@@ -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
 
@@ -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
  );
@@ -17,6 +17,23 @@ import { useStyleOverride } from './utils';
17
17
  import { store as blockEditorStore } from '../store';
18
18
  import { globalStylesDataKey } from '../store/private-keys';
19
19
 
20
+ const VARIATION_PREFIX = 'is-style-';
21
+
22
+ function getVariationMatches( className ) {
23
+ if ( ! className ) {
24
+ return [];
25
+ }
26
+ return className.split( /\s+/ ).reduce( ( matches, name ) => {
27
+ if ( name.startsWith( VARIATION_PREFIX ) ) {
28
+ const match = name.slice( VARIATION_PREFIX.length );
29
+ if ( match !== 'default' ) {
30
+ matches.push( match );
31
+ }
32
+ }
33
+ return matches;
34
+ }, [] );
35
+ }
36
+
20
37
  /**
21
38
  * Get the first block style variation that has been registered from the class string.
22
39
  *
@@ -28,14 +45,13 @@ import { globalStylesDataKey } from '../store/private-keys';
28
45
  function getVariationNameFromClass( className, registeredStyles = [] ) {
29
46
  // The global flag affects how capturing groups work in JS. So the regex
30
47
  // below will only return full CSS classes not just the variation name.
31
- const matches = className?.match( /\bis-style-(?!default)(\S+)\b/g );
48
+ const matches = getVariationMatches( className );
32
49
 
33
50
  if ( ! matches ) {
34
51
  return null;
35
52
  }
36
53
 
37
- for ( const variationClass of matches ) {
38
- const variation = variationClass.substring( 9 ); // Remove 'is-style-' prefix.
54
+ for ( const variation of matches ) {
39
55
  if ( registeredStyles.some( ( style ) => style.name === variation ) ) {
40
56
  return variation;
41
57
  }
@@ -94,7 +110,7 @@ function useBlockProps( { name, className, clientId } ) {
94
110
 
95
111
  const registeredStyles = getBlockStyles( name );
96
112
  const variation = getVariationNameFromClass( className, registeredStyles );
97
- const variationClass = `is-style-${ variation }-${ clientId }`;
113
+ const variationClass = `${ VARIATION_PREFIX }${ variation }-${ clientId }`;
98
114
 
99
115
  const { settings, styles } = useBlockSyleVariation(
100
116
  name,
@@ -116,7 +132,7 @@ function useBlockProps( { name, className, clientId } ) {
116
132
  const hasBlockGapSupport = false;
117
133
  const hasFallbackGapSupport = true;
118
134
  const disableLayoutStyles = true;
119
- const isTemplate = true;
135
+ const disableRootPadding = true;
120
136
 
121
137
  return toStyles(
122
138
  variationConfig,
@@ -124,7 +140,7 @@ function useBlockProps( { name, className, clientId } ) {
124
140
  hasBlockGapSupport,
125
141
  hasFallbackGapSupport,
126
142
  disableLayoutStyles,
127
- isTemplate,
143
+ disableRootPadding,
128
144
  {
129
145
  blockGap: false,
130
146
  blockStyles: true,
@@ -132,6 +148,7 @@ function useBlockProps( { name, className, clientId } ) {
132
148
  marginReset: false,
133
149
  presets: false,
134
150
  rootPadding: false,
151
+ variationStyles: true,
135
152
  }
136
153
  );
137
154
  }, [ variation, settings, styles, getBlockStyles, clientId ] );
@@ -152,5 +169,6 @@ function useBlockProps( { name, className, clientId } ) {
152
169
  export default {
153
170
  hasSupport: () => true,
154
171
  attributeKeys: [ 'className' ],
172
+ isMatch: ( { className } ) => getVariationMatches( className ).length > 0,
155
173
  useBlockProps,
156
174
  };
@@ -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
 
@@ -582,6 +582,7 @@ export function createBlockListBlockFilter( features ) {
582
582
  hasSupport,
583
583
  attributeKeys = [],
584
584
  useBlockProps,
585
+ isMatch,
585
586
  } = feature;
586
587
 
587
588
  const neededProps = {};
@@ -595,7 +596,8 @@ export function createBlockListBlockFilter( features ) {
595
596
  // Skip rendering if none of the needed attributes are
596
597
  // set.
597
598
  ! Object.keys( neededProps ).length ||
598
- ! hasSupport( props.name )
599
+ ! hasSupport( props.name ) ||
600
+ ( isMatch && ! isMatch( neededProps ) )
599
601
  ) {
600
602
  return null;
601
603
  }
@@ -5,6 +5,6 @@ import { __dangerousOptInToUnstableAPIsOnlyForCoreModules } from '@wordpress/pri
5
5
 
6
6
  export const { lock, unlock } =
7
7
  __dangerousOptInToUnstableAPIsOnlyForCoreModules(
8
- 'I know using unstable features means my theme or plugin will inevitably break in the next version of WordPress.',
8
+ 'I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.',
9
9
  '@wordpress/block-editor'
10
10
  );
@@ -43,6 +43,7 @@ import { PrivateBlockPopover } from './components/block-popover';
43
43
  import { PrivateInserterLibrary } from './components/inserter/library';
44
44
  import { PrivatePublishDateTimePicker } from './components/publish-date-time-picker';
45
45
  import useSpacingSizes from './components/spacing-sizes-control/hooks/use-spacing-sizes';
46
+ import useBlockDisplayTitle from './components/block-title/use-block-display-title';
46
47
 
47
48
  /**
48
49
  * Private @wordpress/block-editor APIs.
@@ -86,4 +87,5 @@ lock( privateApis, {
86
87
  PrivateBlockPopover,
87
88
  PrivatePublishDateTimePicker,
88
89
  useSpacingSizes,
90
+ useBlockDisplayTitle,
89
91
  } );
@@ -409,7 +409,7 @@ const createOnMove =
409
409
  ( clientIds, rootClientId ) =>
410
410
  ( { select, dispatch } ) => {
411
411
  // If one of the blocks is locked or the parent is locked, we cannot move any block.
412
- const canMoveBlocks = select.canMoveBlocks( clientIds, rootClientId );
412
+ const canMoveBlocks = select.canMoveBlocks( clientIds );
413
413
  if ( ! canMoveBlocks ) {
414
414
  return;
415
415
  }
@@ -431,10 +431,7 @@ export const moveBlocksUp = createOnMove( 'MOVE_BLOCKS_UP' );
431
431
  export const moveBlocksToPosition =
432
432
  ( clientIds, fromRootClientId = '', toRootClientId = '', index ) =>
433
433
  ( { select, dispatch } ) => {
434
- const canMoveBlocks = select.canMoveBlocks(
435
- clientIds,
436
- fromRootClientId
437
- );
434
+ const canMoveBlocks = select.canMoveBlocks( clientIds );
438
435
 
439
436
  // If one of the blocks is locked or the parent is locked, we cannot move any block.
440
437
  if ( ! canMoveBlocks ) {
@@ -443,10 +440,7 @@ export const moveBlocksToPosition =
443
440
 
444
441
  // If moving inside the same root block the move is always possible.
445
442
  if ( fromRootClientId !== toRootClientId ) {
446
- const canRemoveBlocks = select.canRemoveBlocks(
447
- clientIds,
448
- fromRootClientId
449
- );
443
+ const canRemoveBlocks = select.canRemoveBlocks( clientIds );
450
444
 
451
445
  // If we're moving to another block, it means we're deleting blocks from
452
446
  // the original block, so we need to check if removing is possible.
@@ -988,7 +982,7 @@ export const __unstableSplitSelection =
988
982
  },
989
983
  };
990
984
 
991
- const tail = {
985
+ let tail = {
992
986
  ...blockB,
993
987
  // Only preserve the original client ID if the end is different.
994
988
  clientId:
@@ -1001,6 +995,26 @@ export const __unstableSplitSelection =
1001
995
  },
1002
996
  };
1003
997
 
998
+ // When splitting a block, attempt to convert the tail block to the
999
+ // default block type. For example, when splitting a heading block, the
1000
+ // tail block will be converted to a paragraph block. Note that for
1001
+ // blocks such as a list item and button, this will be skipped because
1002
+ // the default block type cannot be inserted.
1003
+ const defaultBlockName = getDefaultBlockName();
1004
+ if (
1005
+ // A block is only split when the selection is within the same
1006
+ // block.
1007
+ blockA.clientId === blockB.clientId &&
1008
+ defaultBlockName &&
1009
+ tail.name !== defaultBlockName &&
1010
+ select.canInsertBlockType( defaultBlockName, anchorRootClientId )
1011
+ ) {
1012
+ const switched = switchToBlockType( tail, defaultBlockName );
1013
+ if ( switched?.length === 1 ) {
1014
+ tail = switched[ 0 ];
1015
+ }
1016
+ }
1017
+
1004
1018
  if ( ! blocks.length ) {
1005
1019
  dispatch.replaceBlocks( select.getSelectedBlockClientIds(), [
1006
1020
  head,
@@ -105,11 +105,7 @@ export const privateRemoveBlocks =
105
105
  }
106
106
 
107
107
  clientIds = castArray( clientIds );
108
- const rootClientId = select.getBlockRootClientId( clientIds[ 0 ] );
109
- const canRemoveBlocks = select.canRemoveBlocks(
110
- clientIds,
111
- rootClientId
112
- );
108
+ const canRemoveBlocks = select.canRemoveBlocks( clientIds );
113
109
 
114
110
  if ( ! canRemoveBlocks ) {
115
111
  return;
@@ -1712,13 +1712,12 @@ export function canInsertBlocks( state, clientIds, rootClientId = null ) {
1712
1712
  /**
1713
1713
  * Determines if the given block is allowed to be deleted.
1714
1714
  *
1715
- * @param {Object} state Editor state.
1716
- * @param {string} clientId The block client Id.
1717
- * @param {?string} rootClientId Optional root client ID of block list.
1715
+ * @param {Object} state Editor state.
1716
+ * @param {string} clientId The block client Id.
1718
1717
  *
1719
1718
  * @return {boolean} Whether the given block is allowed to be removed.
1720
1719
  */
1721
- export function canRemoveBlock( state, clientId, rootClientId = null ) {
1720
+ export function canRemoveBlock( state, clientId ) {
1722
1721
  const attributes = getBlockAttributes( state, clientId );
1723
1722
  if ( attributes === null ) {
1724
1723
  return true;
@@ -1726,6 +1725,8 @@ export function canRemoveBlock( state, clientId, rootClientId = null ) {
1726
1725
  if ( attributes.lock?.remove !== undefined ) {
1727
1726
  return ! attributes.lock.remove;
1728
1727
  }
1728
+
1729
+ const rootClientId = getBlockRootClientId( state, clientId );
1729
1730
  if ( getTemplateLock( state, rootClientId ) ) {
1730
1731
  return false;
1731
1732
  }
@@ -1736,28 +1737,24 @@ export function canRemoveBlock( state, clientId, rootClientId = null ) {
1736
1737
  /**
1737
1738
  * Determines if the given blocks are allowed to be removed.
1738
1739
  *
1739
- * @param {Object} state Editor state.
1740
- * @param {string} clientIds The block client IDs to be removed.
1741
- * @param {?string} rootClientId Optional root client ID of block list.
1740
+ * @param {Object} state Editor state.
1741
+ * @param {string} clientIds The block client IDs to be removed.
1742
1742
  *
1743
1743
  * @return {boolean} Whether the given blocks are allowed to be removed.
1744
1744
  */
1745
- export function canRemoveBlocks( state, clientIds, rootClientId = null ) {
1746
- return clientIds.every( ( clientId ) =>
1747
- canRemoveBlock( state, clientId, rootClientId )
1748
- );
1745
+ export function canRemoveBlocks( state, clientIds ) {
1746
+ return clientIds.every( ( clientId ) => canRemoveBlock( state, clientId ) );
1749
1747
  }
1750
1748
 
1751
1749
  /**
1752
1750
  * Determines if the given block is allowed to be moved.
1753
1751
  *
1754
- * @param {Object} state Editor state.
1755
- * @param {string} clientId The block client Id.
1756
- * @param {?string} rootClientId Optional root client ID of block list.
1752
+ * @param {Object} state Editor state.
1753
+ * @param {string} clientId The block client Id.
1757
1754
  *
1758
1755
  * @return {boolean | undefined} Whether the given block is allowed to be moved.
1759
1756
  */
1760
- export function canMoveBlock( state, clientId, rootClientId = null ) {
1757
+ export function canMoveBlock( state, clientId ) {
1761
1758
  const attributes = getBlockAttributes( state, clientId );
1762
1759
  if ( attributes === null ) {
1763
1760
  return true;
@@ -1765,6 +1762,8 @@ export function canMoveBlock( state, clientId, rootClientId = null ) {
1765
1762
  if ( attributes.lock?.move !== undefined ) {
1766
1763
  return ! attributes.lock.move;
1767
1764
  }
1765
+
1766
+ const rootClientId = getBlockRootClientId( state, clientId );
1768
1767
  if ( getTemplateLock( state, rootClientId ) === 'all' ) {
1769
1768
  return false;
1770
1769
  }
@@ -1774,16 +1773,13 @@ export function canMoveBlock( state, clientId, rootClientId = null ) {
1774
1773
  /**
1775
1774
  * Determines if the given blocks are allowed to be moved.
1776
1775
  *
1777
- * @param {Object} state Editor state.
1778
- * @param {string} clientIds The block client IDs to be moved.
1779
- * @param {?string} rootClientId Optional root client ID of block list.
1776
+ * @param {Object} state Editor state.
1777
+ * @param {string} clientIds The block client IDs to be moved.
1780
1778
  *
1781
1779
  * @return {boolean} Whether the given blocks are allowed to be moved.
1782
1780
  */
1783
- export function canMoveBlocks( state, clientIds, rootClientId = null ) {
1784
- return clientIds.every( ( clientId ) =>
1785
- canMoveBlock( state, clientId, rootClientId )
1786
- );
1781
+ export function canMoveBlocks( state, clientIds ) {
1782
+ return clientIds.every( ( clientId ) => canMoveBlock( state, clientId ) );
1787
1783
  }
1788
1784
 
1789
1785
  /**
@@ -3041,10 +3037,7 @@ export const isGroupable = createRegistrySelector(
3041
3037
  rootClientId
3042
3038
  );
3043
3039
  const _isGroupable = groupingBlockAvailable && _clientIds.length;
3044
- return (
3045
- _isGroupable &&
3046
- canRemoveBlocks( state, _clientIds, rootClientId )
3047
- );
3040
+ return _isGroupable && canRemoveBlocks( state, _clientIds );
3048
3041
  }
3049
3042
  );
3050
3043
 
package/src/style.scss CHANGED
@@ -1,6 +1,5 @@
1
1
  @import "./autocompleters/style.scss";
2
2
  @import "./components/block-alignment-control/style.scss";
3
- @import "./components/block-bindings-toolbar-indicator/style.scss";
4
3
  @import "./components/block-canvas/style.scss";
5
4
  @import "./components/block-icon/style.scss";
6
5
  @import "./components/block-inspector/style.scss";