@wordpress/block-editor 13.0.1 → 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 (183) 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/date-format-picker/index.js +18 -10
  29. package/build/components/date-format-picker/index.js.map +1 -1
  30. package/build/components/global-styles/hooks.js +1 -1
  31. package/build/components/global-styles/hooks.js.map +1 -1
  32. package/build/components/global-styles/use-global-styles-output.js +14 -1
  33. package/build/components/global-styles/use-global-styles-output.js.map +1 -1
  34. package/build/components/inserter/block-types-tab.native.js +1 -1
  35. package/build/components/inserter/block-types-tab.native.js.map +1 -1
  36. package/build/components/link-control/link-preview.js +12 -1
  37. package/build/components/link-control/link-preview.js.map +1 -1
  38. package/build/components/list-view/block.js +7 -6
  39. package/build/components/list-view/block.js.map +1 -1
  40. package/build/components/list-view/branch.js +3 -1
  41. package/build/components/list-view/branch.js.map +1 -1
  42. package/build/components/list-view/use-clipboard-handler.js +1 -1
  43. package/build/components/list-view/use-clipboard-handler.js.map +1 -1
  44. package/build/components/provider/use-block-sync.js +1 -7
  45. package/build/components/provider/use-block-sync.js.map +1 -1
  46. package/build/components/rich-text/index.native.js +4 -0
  47. package/build/components/rich-text/index.native.js.map +1 -1
  48. package/build/components/rich-text/native/index.native.js +6 -4
  49. package/build/components/rich-text/native/index.native.js.map +1 -1
  50. package/build/components/spacing-sizes-control/hooks/use-spacing-sizes.js +4 -4
  51. package/build/components/spacing-sizes-control/hooks/use-spacing-sizes.js.map +1 -1
  52. package/build/components/use-block-commands/index.js +3 -3
  53. package/build/components/use-block-commands/index.js.map +1 -1
  54. package/build/hooks/block-bindings.js +19 -16
  55. package/build/hooks/block-bindings.js.map +1 -1
  56. package/build/hooks/block-style-variation.js +2 -2
  57. package/build/hooks/block-style-variation.js.map +1 -1
  58. package/build/hooks/use-bindings-attributes.js +7 -2
  59. package/build/hooks/use-bindings-attributes.js.map +1 -1
  60. package/build/private-apis.js +3 -1
  61. package/build/private-apis.js.map +1 -1
  62. package/build/store/actions.js +3 -3
  63. package/build/store/actions.js.map +1 -1
  64. package/build/store/private-actions.js +1 -36
  65. package/build/store/private-actions.js.map +1 -1
  66. package/build/store/selectors.js +17 -19
  67. package/build/store/selectors.js.map +1 -1
  68. package/build-module/components/block-actions/index.js +4 -6
  69. package/build-module/components/block-actions/index.js.map +1 -1
  70. package/build-module/components/block-draggable/index.js +1 -1
  71. package/build-module/components/block-draggable/index.js.map +1 -1
  72. package/build-module/components/block-list/block.js +2 -2
  73. package/build-module/components/block-list/block.js.map +1 -1
  74. package/build-module/components/block-list/block.native.js +2 -2
  75. package/build-module/components/block-list/block.native.js.map +1 -1
  76. package/build-module/components/block-list/use-in-between-inserter.js +3 -1
  77. package/build-module/components/block-list/use-in-between-inserter.js.map +1 -1
  78. package/build-module/components/block-lock/use-block-lock.js +2 -4
  79. package/build-module/components/block-lock/use-block-lock.js.map +1 -1
  80. package/build-module/components/block-mover/index.js +1 -1
  81. package/build-module/components/block-mover/index.js.map +1 -1
  82. package/build-module/components/block-mover/index.native.js +1 -1
  83. package/build-module/components/block-mover/index.native.js.map +1 -1
  84. package/build-module/components/block-settings-menu/block-settings-dropdown.js +1 -1
  85. package/build-module/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
  86. package/build-module/components/block-switcher/block-variation-transformations.js +1 -3
  87. package/build-module/components/block-switcher/block-variation-transformations.js.map +1 -1
  88. package/build-module/components/block-switcher/index.js +15 -8
  89. package/build-module/components/block-switcher/index.js.map +1 -1
  90. package/build-module/components/block-toolbar/index.js +7 -10
  91. package/build-module/components/block-toolbar/index.js.map +1 -1
  92. package/build-module/components/block-tools/block-selection-button.js +2 -2
  93. package/build-module/components/block-tools/block-selection-button.js.map +1 -1
  94. package/build-module/components/date-format-picker/index.js +19 -11
  95. package/build-module/components/date-format-picker/index.js.map +1 -1
  96. package/build-module/components/global-styles/hooks.js +1 -1
  97. package/build-module/components/global-styles/hooks.js.map +1 -1
  98. package/build-module/components/global-styles/use-global-styles-output.js +14 -1
  99. package/build-module/components/global-styles/use-global-styles-output.js.map +1 -1
  100. package/build-module/components/inserter/block-types-tab.native.js +1 -1
  101. package/build-module/components/inserter/block-types-tab.native.js.map +1 -1
  102. package/build-module/components/link-control/link-preview.js +14 -1
  103. package/build-module/components/link-control/link-preview.js.map +1 -1
  104. package/build-module/components/list-view/block.js +7 -6
  105. package/build-module/components/list-view/block.js.map +1 -1
  106. package/build-module/components/list-view/branch.js +3 -1
  107. package/build-module/components/list-view/branch.js.map +1 -1
  108. package/build-module/components/list-view/use-clipboard-handler.js +1 -1
  109. package/build-module/components/list-view/use-clipboard-handler.js.map +1 -1
  110. package/build-module/components/provider/use-block-sync.js +1 -7
  111. package/build-module/components/provider/use-block-sync.js.map +1 -1
  112. package/build-module/components/rich-text/index.native.js +4 -0
  113. package/build-module/components/rich-text/index.native.js.map +1 -1
  114. package/build-module/components/rich-text/native/index.native.js +6 -4
  115. package/build-module/components/rich-text/native/index.native.js.map +1 -1
  116. package/build-module/components/spacing-sizes-control/hooks/use-spacing-sizes.js +4 -4
  117. package/build-module/components/spacing-sizes-control/hooks/use-spacing-sizes.js.map +1 -1
  118. package/build-module/components/use-block-commands/index.js +3 -3
  119. package/build-module/components/use-block-commands/index.js.map +1 -1
  120. package/build-module/hooks/block-bindings.js +20 -17
  121. package/build-module/hooks/block-bindings.js.map +1 -1
  122. package/build-module/hooks/block-style-variation.js +2 -2
  123. package/build-module/hooks/block-style-variation.js.map +1 -1
  124. package/build-module/hooks/use-bindings-attributes.js +7 -2
  125. package/build-module/hooks/use-bindings-attributes.js.map +1 -1
  126. package/build-module/private-apis.js +3 -1
  127. package/build-module/private-apis.js.map +1 -1
  128. package/build-module/store/actions.js +3 -3
  129. package/build-module/store/actions.js.map +1 -1
  130. package/build-module/store/private-actions.js +1 -35
  131. package/build-module/store/private-actions.js.map +1 -1
  132. package/build-module/store/selectors.js +17 -19
  133. package/build-module/store/selectors.js.map +1 -1
  134. package/build-style/style-rtl.css +7 -15
  135. package/build-style/style.css +7 -15
  136. package/package.json +31 -31
  137. package/src/components/block-actions/index.js +3 -7
  138. package/src/components/block-draggable/index.js +1 -1
  139. package/src/components/block-list/block.js +2 -2
  140. package/src/components/block-list/block.native.js +2 -2
  141. package/src/components/block-list/use-in-between-inserter.js +3 -1
  142. package/src/components/block-lock/use-block-lock.js +2 -4
  143. package/src/components/block-mover/index.js +1 -1
  144. package/src/components/block-mover/index.native.js +1 -1
  145. package/src/components/block-settings-menu/block-settings-dropdown.js +1 -1
  146. package/src/components/block-switcher/block-variation-transformations.js +4 -9
  147. package/src/components/block-switcher/index.js +27 -12
  148. package/src/components/block-switcher/style.scss +5 -0
  149. package/src/components/block-toolbar/index.js +7 -9
  150. package/src/components/block-toolbar/style.scss +9 -6
  151. package/src/components/block-tools/block-selection-button.js +2 -2
  152. package/src/components/date-format-picker/index.js +25 -13
  153. package/src/components/global-styles/hooks.js +1 -4
  154. package/src/components/global-styles/use-global-styles-output.js +24 -4
  155. package/src/components/inserter/block-types-tab.native.js +2 -1
  156. package/src/components/link-control/link-preview.js +18 -1
  157. package/src/components/list-view/block.js +7 -7
  158. package/src/components/list-view/branch.js +5 -1
  159. package/src/components/list-view/use-clipboard-handler.js +1 -6
  160. package/src/components/provider/use-block-sync.js +0 -6
  161. package/src/components/rich-text/index.native.js +4 -0
  162. package/src/components/rich-text/native/index.native.js +3 -1
  163. package/src/components/spacing-sizes-control/hooks/use-spacing-sizes.js +2 -9
  164. package/src/components/use-block-commands/index.js +3 -4
  165. package/src/hooks/block-bindings.js +28 -22
  166. package/src/hooks/block-style-variation.js +2 -2
  167. package/src/hooks/use-bindings-attributes.js +11 -1
  168. package/src/private-apis.js +2 -0
  169. package/src/store/actions.js +3 -9
  170. package/src/store/private-actions.js +1 -34
  171. package/src/store/selectors.js +19 -26
  172. package/src/style.scss +0 -1
  173. package/build/components/block-bindings-toolbar-indicator/index.js +0 -106
  174. package/build/components/block-bindings-toolbar-indicator/index.js.map +0 -1
  175. package/build/store/undo-ignore.js +0 -11
  176. package/build/store/undo-ignore.js.map +0 -1
  177. package/build-module/components/block-bindings-toolbar-indicator/index.js +0 -99
  178. package/build-module/components/block-bindings-toolbar-indicator/index.js.map +0 -1
  179. package/build-module/store/undo-ignore.js +0 -5
  180. package/build-module/store/undo-ignore.js.map +0 -1
  181. package/src/components/block-bindings-toolbar-indicator/index.js +0 -137
  182. package/src/components/block-bindings-toolbar-indicator/style.scss +0 -12
  183. package/src/store/undo-ignore.js +0 -4
@@ -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;
@@ -3419,10 +3411,10 @@ iframe[name=editor-canvas] {
3419
3411
  border: 0;
3420
3412
  border-left: 1px solid #ddd;
3421
3413
  }
3422
- .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 {
3423
3415
  color: var(--wp-block-synced-color);
3424
3416
  }
3425
- .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 {
3426
3418
  color: var(--wp-block-synced-color);
3427
3419
  }
3428
3420
  .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;
@@ -3420,10 +3412,10 @@ iframe[name=editor-canvas] {
3420
3412
  border: 0;
3421
3413
  border-right: 1px solid #ddd;
3422
3414
  }
3423
- .block-editor-block-toolbar.is-synced .block-editor-block-switcher .components-button .block-editor-block-icon {
3415
+ .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
3416
  color: var(--wp-block-synced-color);
3425
3417
  }
3426
- .block-editor-block-toolbar.is-synced .components-toolbar-button.block-editor-block-switcher__no-switcher-icon:disabled .block-editor-block-icon.has-colors {
3418
+ .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
3419
  color: var(--wp-block-synced-color);
3428
3420
  }
3429
3421
  .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.1.0",
4
4
  "description": "Generic block editor.",
5
5
  "author": "The WordPress Contributors",
6
6
  "license": "GPL-2.0-or-later",
@@ -36,35 +36,35 @@
36
36
  "@emotion/react": "^11.7.1",
37
37
  "@emotion/styled": "^11.6.0",
38
38
  "@react-spring/web": "^9.4.5",
39
- "@wordpress/a11y": "^4.0.1",
40
- "@wordpress/api-fetch": "^7.0.1",
41
- "@wordpress/blob": "^4.0.1",
42
- "@wordpress/blocks": "^13.0.1",
43
- "@wordpress/commands": "^1.0.1",
44
- "@wordpress/components": "^28.0.1",
45
- "@wordpress/compose": "^7.0.1",
46
- "@wordpress/data": "^10.0.1",
47
- "@wordpress/date": "^5.0.1",
48
- "@wordpress/deprecated": "^4.0.1",
49
- "@wordpress/dom": "^4.0.1",
50
- "@wordpress/element": "^6.0.1",
51
- "@wordpress/escape-html": "^3.0.1",
52
- "@wordpress/hooks": "^4.0.1",
53
- "@wordpress/html-entities": "^4.0.1",
54
- "@wordpress/i18n": "^5.0.1",
55
- "@wordpress/icons": "^10.0.1",
56
- "@wordpress/is-shallow-equal": "^5.0.1",
57
- "@wordpress/keyboard-shortcuts": "^5.0.1",
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",
64
- "@wordpress/token-list": "^3.0.1",
65
- "@wordpress/url": "^4.0.1",
66
- "@wordpress/warning": "^3.0.1",
67
- "@wordpress/wordcount": "^4.0.1",
39
+ "@wordpress/a11y": "^4.1.0",
40
+ "@wordpress/api-fetch": "^7.1.0",
41
+ "@wordpress/blob": "^4.1.0",
42
+ "@wordpress/blocks": "^13.1.0",
43
+ "@wordpress/commands": "^1.1.0",
44
+ "@wordpress/components": "^28.1.0",
45
+ "@wordpress/compose": "^7.1.0",
46
+ "@wordpress/data": "^10.1.0",
47
+ "@wordpress/date": "^5.1.0",
48
+ "@wordpress/deprecated": "^4.1.0",
49
+ "@wordpress/dom": "^4.1.0",
50
+ "@wordpress/element": "^6.1.0",
51
+ "@wordpress/escape-html": "^3.1.0",
52
+ "@wordpress/hooks": "^4.1.0",
53
+ "@wordpress/html-entities": "^4.1.0",
54
+ "@wordpress/i18n": "^5.1.0",
55
+ "@wordpress/icons": "^10.1.0",
56
+ "@wordpress/is-shallow-equal": "^5.1.0",
57
+ "@wordpress/keyboard-shortcuts": "^5.1.0",
58
+ "@wordpress/keycodes": "^4.1.0",
59
+ "@wordpress/notices": "^5.1.0",
60
+ "@wordpress/preferences": "^4.1.0",
61
+ "@wordpress/private-apis": "^1.1.0",
62
+ "@wordpress/rich-text": "^7.1.0",
63
+ "@wordpress/style-engine": "^2.1.0",
64
+ "@wordpress/token-list": "^3.1.0",
65
+ "@wordpress/url": "^4.1.0",
66
+ "@wordpress/warning": "^3.1.0",
67
+ "@wordpress/wordcount": "^4.1.0",
68
68
  "change-case": "^4.1.2",
69
69
  "clsx": "^2.1.1",
70
70
  "colord": "^2.7.0",
@@ -86,5 +86,5 @@
86
86
  "publishConfig": {
87
87
  "access": "public"
88
88
  },
89
- "gitHead": "0e973525f7787401b5a544e0727774d52a78639f"
89
+ "gitHead": "66d3bf12e67d16deddc4b4a9ec42e1d0bed3479a"
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 ]
@@ -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 (
@@ -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