@wordpress/block-editor 13.0.1 → 13.0.2

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 (157) 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-tools/block-selection-button.js +2 -2
  26. package/build/components/block-tools/block-selection-button.js.map +1 -1
  27. package/build/components/global-styles/hooks.js +1 -1
  28. package/build/components/global-styles/hooks.js.map +1 -1
  29. package/build/components/global-styles/use-global-styles-output.js +14 -1
  30. package/build/components/global-styles/use-global-styles-output.js.map +1 -1
  31. package/build/components/list-view/block.js +7 -6
  32. package/build/components/list-view/block.js.map +1 -1
  33. package/build/components/list-view/branch.js +3 -1
  34. package/build/components/list-view/branch.js.map +1 -1
  35. package/build/components/list-view/use-clipboard-handler.js +1 -1
  36. package/build/components/list-view/use-clipboard-handler.js.map +1 -1
  37. package/build/components/spacing-sizes-control/hooks/use-spacing-sizes.js +4 -4
  38. package/build/components/spacing-sizes-control/hooks/use-spacing-sizes.js.map +1 -1
  39. package/build/components/use-block-commands/index.js +3 -3
  40. package/build/components/use-block-commands/index.js.map +1 -1
  41. package/build/hooks/block-bindings.js +19 -16
  42. package/build/hooks/block-bindings.js.map +1 -1
  43. package/build/hooks/block-style-variation.js +22 -4
  44. package/build/hooks/block-style-variation.js.map +1 -1
  45. package/build/hooks/use-bindings-attributes.js +7 -2
  46. package/build/hooks/use-bindings-attributes.js.map +1 -1
  47. package/build/hooks/utils.js +3 -2
  48. package/build/hooks/utils.js.map +1 -1
  49. package/build/lock-unlock.js +1 -1
  50. package/build/lock-unlock.js.map +1 -1
  51. package/build/private-apis.js +3 -1
  52. package/build/private-apis.js.map +1 -1
  53. package/build/store/actions.js +20 -4
  54. package/build/store/actions.js.map +1 -1
  55. package/build/store/private-actions.js +1 -2
  56. package/build/store/private-actions.js.map +1 -1
  57. package/build/store/selectors.js +17 -19
  58. package/build/store/selectors.js.map +1 -1
  59. package/build-module/components/block-actions/index.js +4 -6
  60. package/build-module/components/block-actions/index.js.map +1 -1
  61. package/build-module/components/block-draggable/index.js +1 -1
  62. package/build-module/components/block-draggable/index.js.map +1 -1
  63. package/build-module/components/block-list/block.js +2 -2
  64. package/build-module/components/block-list/block.js.map +1 -1
  65. package/build-module/components/block-list/block.native.js +2 -2
  66. package/build-module/components/block-list/block.native.js.map +1 -1
  67. package/build-module/components/block-list/use-in-between-inserter.js +3 -1
  68. package/build-module/components/block-list/use-in-between-inserter.js.map +1 -1
  69. package/build-module/components/block-lock/use-block-lock.js +2 -4
  70. package/build-module/components/block-lock/use-block-lock.js.map +1 -1
  71. package/build-module/components/block-mover/index.js +1 -1
  72. package/build-module/components/block-mover/index.js.map +1 -1
  73. package/build-module/components/block-mover/index.native.js +1 -1
  74. package/build-module/components/block-mover/index.native.js.map +1 -1
  75. package/build-module/components/block-settings-menu/block-settings-dropdown.js +1 -1
  76. package/build-module/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
  77. package/build-module/components/block-switcher/block-variation-transformations.js +1 -3
  78. package/build-module/components/block-switcher/block-variation-transformations.js.map +1 -1
  79. package/build-module/components/block-switcher/index.js +15 -8
  80. package/build-module/components/block-switcher/index.js.map +1 -1
  81. package/build-module/components/block-toolbar/index.js +7 -10
  82. package/build-module/components/block-toolbar/index.js.map +1 -1
  83. package/build-module/components/block-tools/block-selection-button.js +2 -2
  84. package/build-module/components/block-tools/block-selection-button.js.map +1 -1
  85. package/build-module/components/global-styles/hooks.js +1 -1
  86. package/build-module/components/global-styles/hooks.js.map +1 -1
  87. package/build-module/components/global-styles/use-global-styles-output.js +14 -1
  88. package/build-module/components/global-styles/use-global-styles-output.js.map +1 -1
  89. package/build-module/components/list-view/block.js +7 -6
  90. package/build-module/components/list-view/block.js.map +1 -1
  91. package/build-module/components/list-view/branch.js +3 -1
  92. package/build-module/components/list-view/branch.js.map +1 -1
  93. package/build-module/components/list-view/use-clipboard-handler.js +1 -1
  94. package/build-module/components/list-view/use-clipboard-handler.js.map +1 -1
  95. package/build-module/components/spacing-sizes-control/hooks/use-spacing-sizes.js +4 -4
  96. package/build-module/components/spacing-sizes-control/hooks/use-spacing-sizes.js.map +1 -1
  97. package/build-module/components/use-block-commands/index.js +3 -3
  98. package/build-module/components/use-block-commands/index.js.map +1 -1
  99. package/build-module/hooks/block-bindings.js +20 -17
  100. package/build-module/hooks/block-bindings.js.map +1 -1
  101. package/build-module/hooks/block-style-variation.js +21 -4
  102. package/build-module/hooks/block-style-variation.js.map +1 -1
  103. package/build-module/hooks/use-bindings-attributes.js +7 -2
  104. package/build-module/hooks/use-bindings-attributes.js.map +1 -1
  105. package/build-module/hooks/utils.js +3 -2
  106. package/build-module/hooks/utils.js.map +1 -1
  107. package/build-module/lock-unlock.js +1 -1
  108. package/build-module/lock-unlock.js.map +1 -1
  109. package/build-module/private-apis.js +3 -1
  110. package/build-module/private-apis.js.map +1 -1
  111. package/build-module/store/actions.js +20 -4
  112. package/build-module/store/actions.js.map +1 -1
  113. package/build-module/store/private-actions.js +1 -2
  114. package/build-module/store/private-actions.js.map +1 -1
  115. package/build-module/store/selectors.js +17 -19
  116. package/build-module/store/selectors.js.map +1 -1
  117. package/build-style/style-rtl.css +8 -17
  118. package/build-style/style.css +8 -17
  119. package/package.json +12 -12
  120. package/src/components/block-actions/index.js +3 -7
  121. package/src/components/block-draggable/index.js +1 -1
  122. package/src/components/block-list/block.js +2 -2
  123. package/src/components/block-list/block.native.js +2 -2
  124. package/src/components/block-list/use-in-between-inserter.js +3 -1
  125. package/src/components/block-lock/use-block-lock.js +2 -4
  126. package/src/components/block-mover/index.js +1 -1
  127. package/src/components/block-mover/index.native.js +1 -1
  128. package/src/components/block-settings-menu/block-settings-dropdown.js +1 -1
  129. package/src/components/block-switcher/block-variation-transformations.js +4 -9
  130. package/src/components/block-switcher/index.js +27 -12
  131. package/src/components/block-switcher/style.scss +5 -0
  132. package/src/components/block-toolbar/index.js +7 -9
  133. package/src/components/block-toolbar/style.scss +9 -6
  134. package/src/components/block-tools/block-selection-button.js +2 -2
  135. package/src/components/global-styles/hooks.js +1 -4
  136. package/src/components/global-styles/use-global-styles-output.js +24 -4
  137. package/src/components/list-view/block.js +7 -7
  138. package/src/components/list-view/branch.js +5 -1
  139. package/src/components/list-view/use-clipboard-handler.js +1 -6
  140. package/src/components/spacing-sizes-control/hooks/use-spacing-sizes.js +2 -9
  141. package/src/components/use-block-commands/index.js +3 -4
  142. package/src/hooks/block-bindings.js +28 -22
  143. package/src/hooks/block-style-variation.js +21 -4
  144. package/src/hooks/use-bindings-attributes.js +11 -1
  145. package/src/hooks/utils.js +3 -1
  146. package/src/lock-unlock.js +1 -1
  147. package/src/private-apis.js +2 -0
  148. package/src/store/actions.js +24 -10
  149. package/src/store/private-actions.js +1 -5
  150. package/src/store/selectors.js +19 -26
  151. package/src/style.scss +0 -1
  152. package/build/components/block-bindings-toolbar-indicator/index.js +0 -106
  153. package/build/components/block-bindings-toolbar-indicator/index.js.map +0 -1
  154. package/build-module/components/block-bindings-toolbar-indicator/index.js +0 -99
  155. package/build-module/components/block-bindings-toolbar-indicator/index.js.map +0 -1
  156. package/src/components/block-bindings-toolbar-indicator/index.js +0 -137
  157. package/src/components/block-bindings-toolbar-indicator/style.scss +0 -12
@@ -122,19 +122,6 @@
122
122
  margin-top: 0;
123
123
  }
124
124
 
125
- .block-editor-block-bindings-toolbar-indicator__popover .components-popover__content {
126
- min-width: 260px;
127
- padding: 16px;
128
- }
129
-
130
- .block-editor-block-bindings-toolbar-indicator .block-editor-block-bindings-toolbar-indicator-icon.has-colors svg {
131
- fill: var(--wp-block-synced-color);
132
- }
133
-
134
- .editor-collapsible-block-toolbar .block-editor-block-bindings-toolbar-indicator {
135
- height: 32px;
136
- }
137
-
138
125
  iframe[name=editor-canvas] {
139
126
  box-sizing: border-box;
140
127
  width: 100%;
@@ -1196,6 +1183,11 @@ iframe[name=editor-canvas] {
1196
1183
  margin: 0;
1197
1184
  }
1198
1185
 
1186
+ .block-editor-block-switcher__binding-indicator {
1187
+ display: block;
1188
+ padding: 8px;
1189
+ }
1190
+
1199
1191
  .block-editor-block-types-list > [role=presentation] {
1200
1192
  overflow: hidden;
1201
1193
  display: flex;
@@ -2895,8 +2887,7 @@ iframe[name=editor-canvas] {
2895
2887
  .block-editor-responsive-block-control .components-base-control__help {
2896
2888
  border: 0;
2897
2889
  clip: rect(1px, 1px, 1px, 1px);
2898
- -webkit-clip-path: inset(50%);
2899
- clip-path: inset(50%);
2890
+ clip-path: inset(50%);
2900
2891
  height: 1px;
2901
2892
  margin: -1px;
2902
2893
  overflow: hidden;
@@ -3419,10 +3410,10 @@ iframe[name=editor-canvas] {
3419
3410
  border: 0;
3420
3411
  border-left: 1px solid #ddd;
3421
3412
  }
3422
- .block-editor-block-toolbar.is-synced .block-editor-block-switcher .components-button .block-editor-block-icon {
3413
+ .block-editor-block-toolbar.is-synced .block-editor-block-switcher .components-button .block-editor-block-icon, .block-editor-block-toolbar.is-connected .block-editor-block-switcher .components-button .block-editor-block-icon {
3423
3414
  color: var(--wp-block-synced-color);
3424
3415
  }
3425
- .block-editor-block-toolbar.is-synced .components-toolbar-button.block-editor-block-switcher__no-switcher-icon:disabled .block-editor-block-icon.has-colors {
3416
+ .block-editor-block-toolbar.is-synced .components-toolbar-button.block-editor-block-switcher__no-switcher-icon:disabled .block-editor-block-icon.has-colors, .block-editor-block-toolbar.is-connected .components-toolbar-button.block-editor-block-switcher__no-switcher-icon:disabled .block-editor-block-icon.has-colors {
3426
3417
  color: var(--wp-block-synced-color);
3427
3418
  }
3428
3419
  .block-editor-block-toolbar > :last-child,
@@ -122,19 +122,6 @@
122
122
  margin-top: 0;
123
123
  }
124
124
 
125
- .block-editor-block-bindings-toolbar-indicator__popover .components-popover__content {
126
- min-width: 260px;
127
- padding: 16px;
128
- }
129
-
130
- .block-editor-block-bindings-toolbar-indicator .block-editor-block-bindings-toolbar-indicator-icon.has-colors svg {
131
- fill: var(--wp-block-synced-color);
132
- }
133
-
134
- .editor-collapsible-block-toolbar .block-editor-block-bindings-toolbar-indicator {
135
- height: 32px;
136
- }
137
-
138
125
  iframe[name=editor-canvas] {
139
126
  box-sizing: border-box;
140
127
  width: 100%;
@@ -1196,6 +1183,11 @@ iframe[name=editor-canvas] {
1196
1183
  margin: 0;
1197
1184
  }
1198
1185
 
1186
+ .block-editor-block-switcher__binding-indicator {
1187
+ display: block;
1188
+ padding: 8px;
1189
+ }
1190
+
1199
1191
  .block-editor-block-types-list > [role=presentation] {
1200
1192
  overflow: hidden;
1201
1193
  display: flex;
@@ -2896,8 +2888,7 @@ iframe[name=editor-canvas] {
2896
2888
  .block-editor-responsive-block-control .components-base-control__help {
2897
2889
  border: 0;
2898
2890
  clip: rect(1px, 1px, 1px, 1px);
2899
- -webkit-clip-path: inset(50%);
2900
- clip-path: inset(50%);
2891
+ clip-path: inset(50%);
2901
2892
  height: 1px;
2902
2893
  margin: -1px;
2903
2894
  overflow: hidden;
@@ -3420,10 +3411,10 @@ iframe[name=editor-canvas] {
3420
3411
  border: 0;
3421
3412
  border-right: 1px solid #ddd;
3422
3413
  }
3423
- .block-editor-block-toolbar.is-synced .block-editor-block-switcher .components-button .block-editor-block-icon {
3414
+ .block-editor-block-toolbar.is-synced .block-editor-block-switcher .components-button .block-editor-block-icon, .block-editor-block-toolbar.is-connected .block-editor-block-switcher .components-button .block-editor-block-icon {
3424
3415
  color: var(--wp-block-synced-color);
3425
3416
  }
3426
- .block-editor-block-toolbar.is-synced .components-toolbar-button.block-editor-block-switcher__no-switcher-icon:disabled .block-editor-block-icon.has-colors {
3417
+ .block-editor-block-toolbar.is-synced .components-toolbar-button.block-editor-block-switcher__no-switcher-icon:disabled .block-editor-block-icon.has-colors, .block-editor-block-toolbar.is-connected .components-toolbar-button.block-editor-block-switcher__no-switcher-icon:disabled .block-editor-block-icon.has-colors {
3427
3418
  color: var(--wp-block-synced-color);
3428
3419
  }
3429
3420
  .block-editor-block-toolbar > :last-child,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wordpress/block-editor",
3
- "version": "13.0.1",
3
+ "version": "13.0.2",
4
4
  "description": "Generic block editor.",
5
5
  "author": "The WordPress Contributors",
6
6
  "license": "GPL-2.0-or-later",
@@ -39,11 +39,11 @@
39
39
  "@wordpress/a11y": "^4.0.1",
40
40
  "@wordpress/api-fetch": "^7.0.1",
41
41
  "@wordpress/blob": "^4.0.1",
42
- "@wordpress/blocks": "^13.0.1",
43
- "@wordpress/commands": "^1.0.1",
44
- "@wordpress/components": "^28.0.1",
42
+ "@wordpress/blocks": "^13.0.2",
43
+ "@wordpress/commands": "^1.0.2",
44
+ "@wordpress/components": "^28.0.2",
45
45
  "@wordpress/compose": "^7.0.1",
46
- "@wordpress/data": "^10.0.1",
46
+ "@wordpress/data": "^10.0.2",
47
47
  "@wordpress/date": "^5.0.1",
48
48
  "@wordpress/deprecated": "^4.0.1",
49
49
  "@wordpress/dom": "^4.0.1",
@@ -54,13 +54,13 @@
54
54
  "@wordpress/i18n": "^5.0.1",
55
55
  "@wordpress/icons": "^10.0.1",
56
56
  "@wordpress/is-shallow-equal": "^5.0.1",
57
- "@wordpress/keyboard-shortcuts": "^5.0.1",
57
+ "@wordpress/keyboard-shortcuts": "^5.0.2",
58
58
  "@wordpress/keycodes": "^4.0.1",
59
- "@wordpress/notices": "^5.0.1",
60
- "@wordpress/preferences": "^4.0.1",
61
- "@wordpress/private-apis": "^1.0.1",
62
- "@wordpress/rich-text": "^7.0.1",
63
- "@wordpress/style-engine": "^2.0.1",
59
+ "@wordpress/notices": "^5.0.2",
60
+ "@wordpress/preferences": "^4.0.2",
61
+ "@wordpress/private-apis": "^1.0.2",
62
+ "@wordpress/rich-text": "^7.0.2",
63
+ "@wordpress/style-engine": "^2.0.2",
64
64
  "@wordpress/token-list": "^3.0.1",
65
65
  "@wordpress/url": "^4.0.1",
66
66
  "@wordpress/warning": "^3.0.1",
@@ -86,5 +86,5 @@
86
86
  "publishConfig": {
87
87
  "access": "public"
88
88
  },
89
- "gitHead": "0e973525f7787401b5a544e0727774d52a78639f"
89
+ "gitHead": "a68c6b5ef53956cccf4961d53d79b6af7e00ae60"
90
90
  }
@@ -31,12 +31,10 @@ export default function BlockActions( {
31
31
  getDirectInsertBlock,
32
32
  canMoveBlocks,
33
33
  canRemoveBlocks,
34
- getBlockEditingMode,
35
34
  } = select( blockEditorStore );
36
35
 
37
36
  const blocks = getBlocksByClientId( clientIds );
38
37
  const rootClientId = getBlockRootClientId( clientIds[ 0 ] );
39
- const rootBlockEditingMode = getBlockEditingMode( rootClientId );
40
38
  const canInsertDefaultBlock = canInsertBlockType(
41
39
  getDefaultBlockName(),
42
40
  rootClientId
@@ -46,11 +44,9 @@ export default function BlockActions( {
46
44
  : null;
47
45
 
48
46
  return {
49
- canMove: canMoveBlocks( clientIds, rootClientId ),
50
- canRemove: canRemoveBlocks( clientIds, rootClientId ),
51
- canInsertBlock:
52
- ( canInsertDefaultBlock || !! directInsertBlock ) &&
53
- rootBlockEditingMode === 'default',
47
+ canMove: canMoveBlocks( clientIds ),
48
+ canRemove: canRemoveBlocks( clientIds ),
49
+ canInsertBlock: canInsertDefaultBlock || !! directInsertBlock,
54
50
  canCopyStyles: blocks.every( ( block ) => {
55
51
  return (
56
52
  !! block &&
@@ -53,7 +53,7 @@ const BlockDraggable = ( {
53
53
 
54
54
  return {
55
55
  srcRootClientId: rootClientId,
56
- isDraggable: canMoveBlocks( clientIds, rootClientId ),
56
+ isDraggable: canMoveBlocks( clientIds ),
57
57
  icon: variation?.icon || _getBlockType( blockName )?.icon,
58
58
  visibleInserter: isBlockInsertionPointVisible(),
59
59
  getBlockType: _getBlockType,
@@ -623,8 +623,8 @@ function BlockListBlockProvider( props ) {
623
623
  }
624
624
 
625
625
  const _isSelected = isBlockSelected( clientId );
626
- const canRemove = canRemoveBlock( clientId, rootClientId );
627
- const canMove = canMoveBlock( clientId, rootClientId );
626
+ const canRemove = canRemoveBlock( clientId );
627
+ const canMove = canMoveBlock( clientId );
628
628
  const match = getActiveBlockVariation( blockName, attributes );
629
629
  const isMultiSelected = isBlockMultiSelected( clientId );
630
630
  const checkDeep = true;
@@ -432,8 +432,8 @@ const applyWithSelect = withSelect( ( select, { clientId, rootClientId } ) => {
432
432
  const attributes = getBlockAttributes( clientId );
433
433
  const isSelected = isBlockSelected( clientId );
434
434
  const templateLock = getTemplateLock( rootClientId );
435
- const canRemove = canRemoveBlock( clientId, rootClientId );
436
- const canMove = canMoveBlock( clientId, rootClientId );
435
+ const canRemove = canRemoveBlock( clientId );
436
+ const canMove = canMoveBlock( clientId );
437
437
 
438
438
  // The fallback to `{}` is a temporary fix.
439
439
  // This function should never be called when a block is not present in
@@ -40,7 +40,9 @@ export function useInBetweenInserter() {
40
40
  }
41
41
 
42
42
  function onMouseMove( event ) {
43
- if ( openRef.current ) {
43
+ // openRef is the reference to the insertion point between blocks.
44
+ // If the reference is not set or the insertion point is already open, return.
45
+ if ( openRef === undefined || openRef.current ) {
44
46
  return;
45
47
  }
46
48
 
@@ -24,14 +24,12 @@ export default function useBlockLock( clientId ) {
24
24
  canRemoveBlock,
25
25
  canLockBlockType,
26
26
  getBlockName,
27
- getBlockRootClientId,
28
27
  getTemplateLock,
29
28
  } = select( blockEditorStore );
30
- const rootClientId = getBlockRootClientId( clientId );
31
29
 
32
30
  const canEdit = canEditBlock( clientId );
33
- const canMove = canMoveBlock( clientId, rootClientId );
34
- const canRemove = canRemoveBlock( clientId, rootClientId );
31
+ const canMove = canMoveBlock( clientId );
32
+ const canRemove = canRemoveBlock( clientId );
35
33
 
36
34
  return {
37
35
  canEdit,
@@ -46,7 +46,7 @@ function BlockMover( {
46
46
  const blockOrder = getBlockOrder( _rootClientId );
47
47
 
48
48
  return {
49
- canMove: canMoveBlocks( clientIds, _rootClientId ),
49
+ canMove: canMoveBlocks( clientIds ),
50
50
  rootClientId: _rootClientId,
51
51
  isFirst: firstIndex === 0,
52
52
  isLast: lastIndex === blockOrder.length - 1,
@@ -166,7 +166,7 @@ export default compose(
166
166
  numberOfBlocks: blockOrder.length - 1,
167
167
  isFirst: firstIndex === 0,
168
168
  isLast: lastIndex === blockOrder.length - 1,
169
- canMove: canMoveBlocks( clientIds, rootClientId ),
169
+ canMove: canMoveBlocks( clientIds ),
170
170
  rootClientId,
171
171
  };
172
172
  } ),
@@ -256,7 +256,7 @@ export function BlockSettingsDropdown( {
256
256
  { __( 'Duplicate' ) }
257
257
  </MenuItem>
258
258
  ) }
259
- { canInsertBlock && (
259
+ { canInsertBlock && ! isContentOnly && (
260
260
  <>
261
261
  <MenuItem
262
262
  onClick={ pipe(
@@ -22,17 +22,12 @@ const EMPTY_OBJECT = {};
22
22
  export function useBlockVariationTransforms( { clientIds, blocks } ) {
23
23
  const { activeBlockVariation, blockVariationTransformations } = useSelect(
24
24
  ( select ) => {
25
- const {
26
- getBlockRootClientId,
27
- getBlockAttributes,
28
- canRemoveBlocks,
29
- } = select( blockEditorStore );
25
+ const { getBlockAttributes, canRemoveBlocks } =
26
+ select( blockEditorStore );
30
27
  const { getActiveBlockVariation, getBlockVariations } =
31
28
  select( blocksStore );
32
- const rootClientId = getBlockRootClientId(
33
- Array.isArray( clientIds ) ? clientIds[ 0 ] : clientIds
34
- );
35
- const canRemove = canRemoveBlocks( clientIds, rootClientId );
29
+
30
+ const canRemove = canRemoveBlocks( clientIds );
36
31
  // Only handle single selected blocks for now.
37
32
  if ( blocks.length !== 1 || ! canRemove ) {
38
33
  return EMPTY_OBJECT;
@@ -1,12 +1,14 @@
1
1
  /**
2
2
  * WordPress dependencies
3
3
  */
4
- import { __, _n, sprintf } from '@wordpress/i18n';
4
+ import { __, _n, sprintf, _x } from '@wordpress/i18n';
5
5
  import {
6
6
  DropdownMenu,
7
7
  ToolbarButton,
8
8
  ToolbarGroup,
9
9
  ToolbarItem,
10
+ __experimentalText as Text,
11
+ MenuGroup,
10
12
  } from '@wordpress/components';
11
13
  import {
12
14
  switchToBlockType,
@@ -33,6 +35,7 @@ function BlockSwitcherDropdownMenuContents( {
33
35
  clientIds,
34
36
  hasBlockStyles,
35
37
  canRemove,
38
+ isUsingBindings,
36
39
  } ) {
37
40
  const { replaceBlocks, multiSelect, updateBlockAttributes } =
38
41
  useDispatch( blockEditorStore );
@@ -118,6 +121,17 @@ function BlockSwitcherDropdownMenuContents( {
118
121
  </p>
119
122
  );
120
123
  }
124
+
125
+ const connectedBlockDescription = isSingleBlock
126
+ ? _x(
127
+ 'This block is connected.',
128
+ 'block toolbar button label and description'
129
+ )
130
+ : _x(
131
+ 'These blocks are connected.',
132
+ 'block toolbar button label and description'
133
+ );
134
+
121
135
  return (
122
136
  <div className="block-editor-block-switcher__container">
123
137
  { hasPatternTransformation && (
@@ -156,11 +170,18 @@ function BlockSwitcherDropdownMenuContents( {
156
170
  onSwitch={ onClose }
157
171
  />
158
172
  ) }
173
+ { isUsingBindings && (
174
+ <MenuGroup>
175
+ <Text className="block-editor-block-switcher__binding-indicator">
176
+ { connectedBlockDescription }
177
+ </Text>
178
+ </MenuGroup>
179
+ ) }
159
180
  </div>
160
181
  );
161
182
  }
162
183
 
163
- export const BlockSwitcher = ( { clientIds, disabled } ) => {
184
+ export const BlockSwitcher = ( { clientIds, disabled, isUsingBindings } ) => {
164
185
  const {
165
186
  canRemove,
166
187
  hasBlockStyles,
@@ -170,21 +191,14 @@ export const BlockSwitcher = ( { clientIds, disabled } ) => {
170
191
  isTemplate,
171
192
  } = useSelect(
172
193
  ( select ) => {
173
- const {
174
- getBlockRootClientId,
175
- getBlocksByClientId,
176
- getBlockAttributes,
177
- canRemoveBlocks,
178
- } = select( blockEditorStore );
194
+ const { getBlocksByClientId, getBlockAttributes, canRemoveBlocks } =
195
+ select( blockEditorStore );
179
196
  const { getBlockStyles, getBlockType, getActiveBlockVariation } =
180
197
  select( blocksStore );
181
198
  const _blocks = getBlocksByClientId( clientIds );
182
199
  if ( ! _blocks.length || _blocks.some( ( block ) => ! block ) ) {
183
200
  return { invalidBlocks: true };
184
201
  }
185
- const rootClientId = getBlockRootClientId(
186
- Array.isArray( clientIds ) ? clientIds[ 0 ] : clientIds
187
- );
188
202
  const [ { name: firstBlockName } ] = _blocks;
189
203
  const _isSingleBlockSelected = _blocks.length === 1;
190
204
  const blockType = getBlockType( firstBlockName );
@@ -206,7 +220,7 @@ export const BlockSwitcher = ( { clientIds, disabled } ) => {
206
220
  }
207
221
 
208
222
  return {
209
- canRemove: canRemoveBlocks( clientIds, rootClientId ),
223
+ canRemove: canRemoveBlocks( clientIds ),
210
224
  hasBlockStyles:
211
225
  _isSingleBlockSelected &&
212
226
  !! getBlockStyles( firstBlockName )?.length,
@@ -303,6 +317,7 @@ export const BlockSwitcher = ( { clientIds, disabled } ) => {
303
317
  clientIds={ clientIds }
304
318
  hasBlockStyles={ hasBlockStyles }
305
319
  canRemove={ canRemove }
320
+ isUsingBindings={ isUsingBindings }
306
321
  />
307
322
  ) }
308
323
  </DropdownMenu>
@@ -203,3 +203,8 @@
203
203
  padding: 6px $grid-unit;
204
204
  margin: 0;
205
205
  }
206
+
207
+ .block-editor-block-switcher__binding-indicator {
208
+ display: block;
209
+ padding: $grid-unit;
210
+ }
@@ -35,9 +35,8 @@ import { store as blockEditorStore } from '../../store';
35
35
  import __unstableBlockNameContext from './block-name-context';
36
36
  import NavigableToolbar from '../navigable-toolbar';
37
37
  import Shuffle from './shuffle';
38
- import BlockBindingsIndicator from '../block-bindings-toolbar-indicator';
39
38
  import { useHasBlockToolbar } from './use-has-block-toolbar';
40
- import { canBindBlock } from '../../hooks/use-bindings-attributes';
39
+
41
40
  /**
42
41
  * Renders the block toolbar.
43
42
  *
@@ -62,7 +61,6 @@ export function PrivateBlockToolbar( {
62
61
  blockClientIds,
63
62
  isDefaultEditingMode,
64
63
  blockType,
65
- blockName,
66
64
  toolbarKey,
67
65
  shouldShowVisualToolbar,
68
66
  showParentSelector,
@@ -94,13 +92,14 @@ export function PrivateBlockToolbar( {
94
92
  const isVisual = selectedBlockClientIds.every(
95
93
  ( id ) => getBlockMode( id ) === 'visual'
96
94
  );
97
- const _isUsingBindings = !! getBlockAttributes( selectedBlockClientId )
98
- ?.metadata?.bindings;
95
+ const _isUsingBindings = selectedBlockClientIds.every(
96
+ ( clientId ) =>
97
+ !! getBlockAttributes( clientId )?.metadata?.bindings
98
+ );
99
99
  return {
100
100
  blockClientId: selectedBlockClientId,
101
101
  blockClientIds: selectedBlockClientIds,
102
102
  isDefaultEditingMode: _isDefaultEditingMode,
103
- blockName: _blockName,
104
103
  blockType: selectedBlockClientId && getBlockType( _blockName ),
105
104
  shouldShowVisualToolbar: isValid && isVisual,
106
105
  rootClientId: blockRootClientId,
@@ -146,6 +145,7 @@ export function PrivateBlockToolbar( {
146
145
 
147
146
  const innerClasses = clsx( 'block-editor-block-toolbar', {
148
147
  'is-synced': isSynced,
148
+ 'is-connected': isUsingBindings,
149
149
  } );
150
150
 
151
151
  return (
@@ -167,9 +167,6 @@ export function PrivateBlockToolbar( {
167
167
  { ! isMultiToolbar &&
168
168
  isLargeViewport &&
169
169
  isDefaultEditingMode && <BlockParentSelector /> }
170
- { isUsingBindings && canBindBlock( blockName ) && (
171
- <BlockBindingsIndicator clientIds={ blockClientIds } />
172
- ) }
173
170
  { ( shouldShowVisualToolbar || isMultiToolbar ) &&
174
171
  ( isDefaultEditingMode || isSynced ) && (
175
172
  <div
@@ -180,6 +177,7 @@ export function PrivateBlockToolbar( {
180
177
  <BlockSwitcher
181
178
  clientIds={ blockClientIds }
182
179
  disabled={ ! isDefaultEditingMode }
180
+ isUsingBindings={ isUsingBindings }
183
181
  />
184
182
  { isDefaultEditingMode && (
185
183
  <>
@@ -39,14 +39,17 @@
39
39
  border-right: $border-width solid $gray-300;
40
40
  }
41
41
 
42
- &.is-synced .block-editor-block-switcher .components-button .block-editor-block-icon {
43
- color: var(--wp-block-synced-color);
44
- }
45
-
46
- &.is-synced .components-toolbar-button.block-editor-block-switcher__no-switcher-icon {
47
- &:disabled .block-editor-block-icon.has-colors {
42
+ &.is-synced,
43
+ &.is-connected {
44
+ .block-editor-block-switcher .components-button .block-editor-block-icon {
48
45
  color: var(--wp-block-synced-color);
49
46
  }
47
+
48
+ .components-toolbar-button.block-editor-block-switcher__no-switcher-icon {
49
+ &:disabled .block-editor-block-icon.has-colors {
50
+ color: var(--wp-block-synced-color);
51
+ }
52
+ }
50
53
  }
51
54
 
52
55
  > :last-child,
@@ -107,8 +107,8 @@ function BlockSelectionButton( { clientId, rootClientId } ) {
107
107
  isBlockTemplatePart,
108
108
  isNextBlockTemplatePart,
109
109
  isPrevBlockTemplatePart,
110
- canRemove: canRemoveBlock( clientId, rootClientId ),
111
- canMove: canMoveBlock( clientId, rootClientId ),
110
+ canRemove: canRemoveBlock( clientId ),
111
+ canMove: canMoveBlock( clientId ),
112
112
  };
113
113
  },
114
114
  [ clientId, rootClientId ]
@@ -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
 
@@ -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
  );
@@ -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