@wordpress/block-editor 7.0.3 → 7.0.4

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 (248) hide show
  1. package/build/components/block-actions/index.js +6 -5
  2. package/build/components/block-actions/index.js.map +1 -1
  3. package/build/components/block-alignment-control/use-available-alignments.js +17 -4
  4. package/build/components/block-alignment-control/use-available-alignments.js.map +1 -1
  5. package/build/components/block-inspector/index.js +1 -1
  6. package/build/components/block-inspector/index.js.map +1 -1
  7. package/build/components/block-list/block-html.js +5 -0
  8. package/build/components/block-list/block-html.js.map +1 -1
  9. package/build/components/block-list/block.native.js +2 -2
  10. package/build/components/block-list/block.native.js.map +1 -1
  11. package/build/components/block-list-appender/index.js +9 -1
  12. package/build/components/block-list-appender/index.js.map +1 -1
  13. package/build/components/block-settings-menu/block-settings-dropdown.js +2 -2
  14. package/build/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
  15. package/build/components/block-settings-menu-controls/index.js +10 -3
  16. package/build/components/block-settings-menu-controls/index.js.map +1 -1
  17. package/build/components/block-switcher/block-styles-menu.js +1 -1
  18. package/build/components/block-switcher/block-styles-menu.js.map +1 -1
  19. package/build/components/block-tools/index.js +4 -1
  20. package/build/components/block-tools/index.js.map +1 -1
  21. package/build/components/block-tools/insertion-point.js +96 -7
  22. package/build/components/block-tools/insertion-point.js.map +1 -1
  23. package/build/components/border-radius-control/index.js.map +1 -1
  24. package/build/components/border-radius-control/utils.js +17 -8
  25. package/build/components/border-radius-control/utils.js.map +1 -1
  26. package/build/components/colors-gradients/control.js +17 -13
  27. package/build/components/colors-gradients/control.js.map +1 -1
  28. package/build/components/copy-handler/index.js +3 -3
  29. package/build/components/copy-handler/index.js.map +1 -1
  30. package/build/components/default-block-appender/index.js +2 -2
  31. package/build/components/default-block-appender/index.js.map +1 -1
  32. package/build/components/font-appearance-control/index.js +3 -5
  33. package/build/components/font-appearance-control/index.js.map +1 -1
  34. package/build/components/index.js +0 -18
  35. package/build/components/index.js.map +1 -1
  36. package/build/components/inserter/block-patterns-tab.js +11 -1
  37. package/build/components/inserter/block-patterns-tab.js.map +1 -1
  38. package/build/components/inserter/hooks/use-clipboard-block.native.js +5 -4
  39. package/build/components/inserter/hooks/use-clipboard-block.native.js.map +1 -1
  40. package/build/components/inserter/preview-panel.js +1 -1
  41. package/build/components/inserter/preview-panel.js.map +1 -1
  42. package/build/components/inspector-controls/block-support-slot-container.js +28 -0
  43. package/build/components/inspector-controls/block-support-slot-container.js.map +1 -0
  44. package/build/components/inspector-controls/block-support-tools-panel.js +7 -4
  45. package/build/components/inspector-controls/block-support-tools-panel.js.map +1 -1
  46. package/build/components/inspector-controls/fill.js +16 -1
  47. package/build/components/inspector-controls/fill.js.map +1 -1
  48. package/build/components/inspector-controls/slot.js +5 -2
  49. package/build/components/inspector-controls/slot.js.map +1 -1
  50. package/build/components/list-view/block-contents.js +1 -20
  51. package/build/components/list-view/block-contents.js.map +1 -1
  52. package/build/components/list-view/block.js +5 -36
  53. package/build/components/list-view/block.js.map +1 -1
  54. package/build/components/list-view/list-item.js +3 -2
  55. package/build/components/list-view/list-item.js.map +1 -1
  56. package/build/components/media-placeholder/index.js +26 -17
  57. package/build/components/media-placeholder/index.js.map +1 -1
  58. package/build/components/media-replace-flow/index.js +3 -2
  59. package/build/components/media-replace-flow/index.js.map +1 -1
  60. package/build/components/plain-text/index.native.js +30 -1
  61. package/build/components/plain-text/index.native.js.map +1 -1
  62. package/build/components/rich-text/embed-handler-picker.native.js +65 -0
  63. package/build/components/rich-text/embed-handler-picker.native.js.map +1 -0
  64. package/build/components/rich-text/index.js +5 -1
  65. package/build/components/rich-text/index.js.map +1 -1
  66. package/build/components/rich-text/index.native.js +41 -2
  67. package/build/components/rich-text/index.native.js.map +1 -1
  68. package/build/components/rich-text/use-paste-handler.js +28 -9
  69. package/build/components/rich-text/use-paste-handler.js.map +1 -1
  70. package/build/components/rich-text/utils.js +22 -0
  71. package/build/components/rich-text/utils.js.map +1 -1
  72. package/build/hooks/align.js +10 -7
  73. package/build/hooks/align.js.map +1 -1
  74. package/build/hooks/anchor.js +1 -1
  75. package/build/hooks/anchor.js.map +1 -1
  76. package/build/hooks/font-family.js +93 -23
  77. package/build/hooks/font-family.js.map +1 -1
  78. package/build/hooks/style.js +6 -3
  79. package/build/hooks/style.js.map +1 -1
  80. package/build/layouts/flow.js +4 -1
  81. package/build/layouts/flow.js.map +1 -1
  82. package/build/store/reducer.js +11 -1
  83. package/build/store/reducer.js.map +1 -1
  84. package/build/store/selectors.js +1 -3
  85. package/build/store/selectors.js.map +1 -1
  86. package/build/utils/transform-styles/transforms/wrap.js +16 -0
  87. package/build/utils/transform-styles/transforms/wrap.js.map +1 -1
  88. package/build-module/components/block-actions/index.js +6 -5
  89. package/build-module/components/block-actions/index.js.map +1 -1
  90. package/build-module/components/block-alignment-control/use-available-alignments.js +17 -4
  91. package/build-module/components/block-alignment-control/use-available-alignments.js.map +1 -1
  92. package/build-module/components/block-inspector/index.js +1 -1
  93. package/build-module/components/block-inspector/index.js.map +1 -1
  94. package/build-module/components/block-list/block-html.js +5 -0
  95. package/build-module/components/block-list/block-html.js.map +1 -1
  96. package/build-module/components/block-list/block.native.js +2 -2
  97. package/build-module/components/block-list/block.native.js.map +1 -1
  98. package/build-module/components/block-list-appender/index.js +9 -1
  99. package/build-module/components/block-list-appender/index.js.map +1 -1
  100. package/build-module/components/block-settings-menu/block-settings-dropdown.js +2 -2
  101. package/build-module/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
  102. package/build-module/components/block-settings-menu-controls/index.js +10 -3
  103. package/build-module/components/block-settings-menu-controls/index.js.map +1 -1
  104. package/build-module/components/block-switcher/block-styles-menu.js +1 -1
  105. package/build-module/components/block-switcher/block-styles-menu.js.map +1 -1
  106. package/build-module/components/block-tools/index.js +4 -1
  107. package/build-module/components/block-tools/index.js.map +1 -1
  108. package/build-module/components/block-tools/insertion-point.js +96 -8
  109. package/build-module/components/block-tools/insertion-point.js.map +1 -1
  110. package/build-module/components/border-radius-control/index.js.map +1 -1
  111. package/build-module/components/border-radius-control/utils.js +16 -9
  112. package/build-module/components/border-radius-control/utils.js.map +1 -1
  113. package/build-module/components/colors-gradients/control.js +18 -14
  114. package/build-module/components/colors-gradients/control.js.map +1 -1
  115. package/build-module/components/copy-handler/index.js +3 -3
  116. package/build-module/components/copy-handler/index.js.map +1 -1
  117. package/build-module/components/default-block-appender/index.js +2 -2
  118. package/build-module/components/default-block-appender/index.js.map +1 -1
  119. package/build-module/components/font-appearance-control/index.js +3 -5
  120. package/build-module/components/font-appearance-control/index.js.map +1 -1
  121. package/build-module/components/index.js +0 -2
  122. package/build-module/components/index.js.map +1 -1
  123. package/build-module/components/inserter/block-patterns-tab.js +11 -1
  124. package/build-module/components/inserter/block-patterns-tab.js.map +1 -1
  125. package/build-module/components/inserter/hooks/use-clipboard-block.native.js +5 -4
  126. package/build-module/components/inserter/hooks/use-clipboard-block.native.js.map +1 -1
  127. package/build-module/components/inserter/preview-panel.js +1 -1
  128. package/build-module/components/inserter/preview-panel.js.map +1 -1
  129. package/build-module/components/inspector-controls/block-support-slot-container.js +18 -0
  130. package/build-module/components/inspector-controls/block-support-slot-container.js.map +1 -0
  131. package/build-module/components/inspector-controls/block-support-tools-panel.js +7 -4
  132. package/build-module/components/inspector-controls/block-support-tools-panel.js.map +1 -1
  133. package/build-module/components/inspector-controls/fill.js +16 -2
  134. package/build-module/components/inspector-controls/fill.js.map +1 -1
  135. package/build-module/components/inspector-controls/slot.js +4 -2
  136. package/build-module/components/inspector-controls/slot.js.map +1 -1
  137. package/build-module/components/list-view/block-contents.js +1 -18
  138. package/build-module/components/list-view/block-contents.js.map +1 -1
  139. package/build-module/components/list-view/block.js +7 -37
  140. package/build-module/components/list-view/block.js.map +1 -1
  141. package/build-module/components/list-view/list-item.js +3 -2
  142. package/build-module/components/list-view/list-item.js.map +1 -1
  143. package/build-module/components/media-placeholder/index.js +26 -17
  144. package/build-module/components/media-placeholder/index.js.map +1 -1
  145. package/build-module/components/media-replace-flow/index.js +3 -2
  146. package/build-module/components/media-replace-flow/index.js.map +1 -1
  147. package/build-module/components/plain-text/index.native.js +29 -2
  148. package/build-module/components/plain-text/index.native.js.map +1 -1
  149. package/build-module/components/rich-text/embed-handler-picker.native.js +53 -0
  150. package/build-module/components/rich-text/embed-handler-picker.native.js.map +1 -0
  151. package/build-module/components/rich-text/index.js +4 -1
  152. package/build-module/components/rich-text/index.js.map +1 -1
  153. package/build-module/components/rich-text/index.native.js +41 -3
  154. package/build-module/components/rich-text/index.native.js.map +1 -1
  155. package/build-module/components/rich-text/use-paste-handler.js +28 -9
  156. package/build-module/components/rich-text/use-paste-handler.js.map +1 -1
  157. package/build-module/components/rich-text/utils.js +20 -0
  158. package/build-module/components/rich-text/utils.js.map +1 -1
  159. package/build-module/hooks/align.js +10 -7
  160. package/build-module/hooks/align.js.map +1 -1
  161. package/build-module/hooks/anchor.js +1 -1
  162. package/build-module/hooks/anchor.js.map +1 -1
  163. package/build-module/hooks/font-family.js +91 -24
  164. package/build-module/hooks/font-family.js.map +1 -1
  165. package/build-module/hooks/style.js +6 -3
  166. package/build-module/hooks/style.js.map +1 -1
  167. package/build-module/layouts/flow.js +4 -1
  168. package/build-module/layouts/flow.js.map +1 -1
  169. package/build-module/store/reducer.js +11 -1
  170. package/build-module/store/reducer.js.map +1 -1
  171. package/build-module/store/selectors.js +2 -4
  172. package/build-module/store/selectors.js.map +1 -1
  173. package/build-module/utils/transform-styles/transforms/wrap.js +16 -0
  174. package/build-module/utils/transform-styles/transforms/wrap.js.map +1 -1
  175. package/build-style/style-rtl.css +52 -76
  176. package/build-style/style.css +52 -76
  177. package/package.json +14 -14
  178. package/src/components/block-actions/index.js +5 -5
  179. package/src/components/block-alignment-control/use-available-alignments.js +18 -3
  180. package/src/components/block-inspector/index.js +1 -1
  181. package/src/components/block-list/block-html.js +5 -0
  182. package/src/components/block-list/block.native.js +2 -2
  183. package/src/components/block-list-appender/index.js +8 -0
  184. package/src/components/block-preview/README.md +1 -1
  185. package/src/components/block-preview/style.scss +0 -17
  186. package/src/components/block-settings-menu/block-settings-dropdown.js +2 -2
  187. package/src/components/block-settings-menu-controls/index.js +9 -6
  188. package/src/components/block-switcher/block-styles-menu.js +1 -1
  189. package/src/components/block-tools/index.js +5 -2
  190. package/src/components/block-tools/insertion-point.js +97 -9
  191. package/src/components/block-tools/style.scss +4 -35
  192. package/src/components/border-radius-control/index.js +1 -0
  193. package/src/components/border-radius-control/test/utils.js +216 -0
  194. package/src/components/border-radius-control/utils.js +18 -10
  195. package/src/components/color-palette/test/__snapshots__/control.js.snap +103 -72
  196. package/src/components/colors-gradients/control.js +64 -61
  197. package/src/components/colors-gradients/style.scss +8 -5
  198. package/src/components/colors-gradients/test/control.js +43 -52
  199. package/src/components/copy-handler/index.js +1 -1
  200. package/src/components/default-block-appender/index.js +2 -2
  201. package/src/components/default-block-appender/test/__snapshots__/index.js.snap +3 -3
  202. package/src/components/font-appearance-control/index.js +12 -14
  203. package/src/components/font-appearance-control/style.scss +1 -1
  204. package/src/components/index.js +0 -2
  205. package/src/components/inserter/block-patterns-tab.js +11 -4
  206. package/src/components/inserter/hooks/use-clipboard-block.native.js +3 -2
  207. package/src/components/inserter/preview-panel.js +1 -1
  208. package/src/components/inserter/style.scss +1 -2
  209. package/src/components/inspector-controls/block-support-slot-container.js +10 -0
  210. package/src/components/inspector-controls/block-support-tools-panel.js +4 -2
  211. package/src/components/inspector-controls/fill.js +23 -2
  212. package/src/components/inspector-controls/slot.js +6 -1
  213. package/src/components/link-control/style.scss +9 -5
  214. package/src/components/list-view/block-contents.js +17 -38
  215. package/src/components/list-view/block.js +6 -51
  216. package/src/components/list-view/list-item.js +5 -4
  217. package/src/components/list-view/style.scss +56 -30
  218. package/src/components/media-placeholder/index.js +24 -17
  219. package/src/components/media-replace-flow/README.md +7 -0
  220. package/src/components/media-replace-flow/index.js +2 -0
  221. package/src/components/plain-text/index.native.js +26 -4
  222. package/src/components/rich-text/embed-handler-picker.native.js +67 -0
  223. package/src/components/rich-text/index.js +12 -8
  224. package/src/components/rich-text/index.native.js +35 -1
  225. package/src/components/rich-text/use-paste-handler.js +30 -12
  226. package/src/components/rich-text/utils.js +16 -0
  227. package/src/components/skip-to-selected-block/README.md +39 -0
  228. package/src/hooks/align.js +11 -7
  229. package/src/hooks/anchor.js +2 -2
  230. package/src/hooks/font-family.js +107 -27
  231. package/src/hooks/style.js +14 -8
  232. package/src/layouts/flow.js +4 -1
  233. package/src/store/reducer.js +17 -0
  234. package/src/store/selectors.js +2 -3
  235. package/src/store/test/reducer.js +22 -0
  236. package/src/utils/transform-styles/transforms/test/wrap.js +1 -1
  237. package/src/utils/transform-styles/transforms/wrap.js +16 -0
  238. package/tsconfig.tsbuildinfo +1 -1
  239. package/build/components/list-view/block-slot.js +0 -121
  240. package/build/components/list-view/block-slot.js.map +0 -1
  241. package/build/components/list-view/editor.js +0 -35
  242. package/build/components/list-view/editor.js.map +0 -1
  243. package/build-module/components/list-view/block-slot.js +0 -96
  244. package/build-module/components/list-view/block-slot.js.map +0 -1
  245. package/build-module/components/list-view/editor.js +0 -25
  246. package/build-module/components/list-view/editor.js.map +0 -1
  247. package/src/components/list-view/block-slot.js +0 -120
  248. package/src/components/list-view/editor.js +0 -29
@@ -21,12 +21,13 @@ export default function useClipboardBlock( destinationRootClientId ) {
21
21
  clipboardBlock?.name,
22
22
  destinationRootClientId
23
23
  );
24
+ const blockType = getBlockType( clipboardBlock?.name );
24
25
 
25
- if ( ! canAddClipboardBlock ) {
26
+ if ( ! canAddClipboardBlock || ! blockType ) {
26
27
  return undefined;
27
28
  }
28
29
 
29
- const { icon, name } = getBlockType( clipboardBlock.name );
30
+ const { name, icon } = blockType;
30
31
  const { attributes: initialAttributes, innerBlocks } = clipboardBlock;
31
32
 
32
33
  return {
@@ -22,7 +22,7 @@ function InserterPreviewPanel( { item } ) {
22
22
  return (
23
23
  <div className="block-editor-inserter__preview-container">
24
24
  <div className="block-editor-inserter__preview">
25
- { isReusable || hoveredItemBlockType.example ? (
25
+ { isReusable || hoveredItemBlockType?.example ? (
26
26
  <div className="block-editor-inserter__preview-content">
27
27
  <BlockPreview
28
28
  __experimentalPadding={ 16 }
@@ -117,12 +117,11 @@ $block-inserter-tabs-height: 44px;
117
117
  .block-editor-inserter__tabs {
118
118
  display: flex;
119
119
  flex-direction: column;
120
- margin-top: -$grid-unit-10;
121
120
 
122
121
  .components-tab-panel__tabs {
123
122
  position: sticky;
124
123
  // Computed based off the search input height and paddings
125
- top: $grid-unit-10 + $grid-unit-20 + $grid-unit-60;
124
+ top: $grid-unit-20 + $grid-unit-60;
126
125
  background: $white;
127
126
  z-index: z-index(".block-editor-inserter__tabs .components-tab-panel__tabs");
128
127
  border-bottom: $border-width solid $gray-300;
@@ -0,0 +1,10 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import { __experimentalToolsPanelContext as ToolsPanelContext } from '@wordpress/components';
5
+ import { useContext } from '@wordpress/element';
6
+
7
+ export default function BlockSupportSlotContainer( { Slot, ...props } ) {
8
+ const toolsPanelContext = useContext( ToolsPanelContext );
9
+ return <Slot { ...props } fillProps={ toolsPanelContext } />;
10
+ }
@@ -10,7 +10,7 @@ import { useDispatch, useSelect } from '@wordpress/data';
10
10
  import { store as blockEditorStore } from '../../store';
11
11
  import { cleanEmptyObject } from '../../hooks/utils';
12
12
 
13
- export default function BlockSupportToolsPanel( { children, label, header } ) {
13
+ export default function BlockSupportToolsPanel( { children, group, label } ) {
14
14
  const { clientId, attributes } = useSelect( ( select ) => {
15
15
  const { getBlockAttributes, getSelectedBlockClientId } = select(
16
16
  blockEditorStore
@@ -46,11 +46,13 @@ export default function BlockSupportToolsPanel( { children, label, header } ) {
46
46
 
47
47
  return (
48
48
  <ToolsPanel
49
+ className={ `${ group }-block-support-panel` }
49
50
  label={ label }
50
- header={ header }
51
51
  resetAll={ resetAll }
52
52
  key={ clientId }
53
53
  panelId={ clientId }
54
+ hasInnerWrapper={ true }
55
+ shouldRenderPlaceholderItems={ true } // Required to maintain fills ordering.
54
56
  >
55
57
  { children }
56
58
  </ToolsPanel>
@@ -1,7 +1,15 @@
1
+ /**
2
+ * External dependencies
3
+ */
4
+ import { isEmpty } from 'lodash';
5
+
1
6
  /**
2
7
  * WordPress dependencies
3
8
  */
4
- import { __experimentalStyleProvider as StyleProvider } from '@wordpress/components';
9
+ import {
10
+ __experimentalStyleProvider as StyleProvider,
11
+ __experimentalToolsPanelContext as ToolsPanelContext,
12
+ } from '@wordpress/components';
5
13
  import warning from '@wordpress/warning';
6
14
 
7
15
  /**
@@ -26,7 +34,20 @@ export default function InspectorControlsFill( {
26
34
 
27
35
  return (
28
36
  <StyleProvider document={ document }>
29
- <Fill>{ children }</Fill>
37
+ <Fill>
38
+ { ( fillProps ) => {
39
+ // Children passed to InspectorControlsFill will not have
40
+ // access to any React Context whose Provider is part of
41
+ // the InspectorControlsSlot tree. So we re-create the
42
+ // Provider in this subtree.
43
+ const value = ! isEmpty( fillProps ) ? fillProps : null;
44
+ return (
45
+ <ToolsPanelContext.Provider value={ value }>
46
+ { children }
47
+ </ToolsPanelContext.Provider>
48
+ );
49
+ } }
50
+ </Fill>
30
51
  </StyleProvider>
31
52
  );
32
53
  }
@@ -8,6 +8,7 @@ import warning from '@wordpress/warning';
8
8
  * Internal dependencies
9
9
  */
10
10
  import BlockSupportToolsPanel from './block-support-tools-panel';
11
+ import BlockSupportSlotContainer from './block-support-slot-container';
11
12
  import groups from './groups';
12
13
 
13
14
  export default function InspectorControlsSlot( {
@@ -31,7 +32,11 @@ export default function InspectorControlsSlot( {
31
32
  if ( label ) {
32
33
  return (
33
34
  <BlockSupportToolsPanel group={ group } label={ label }>
34
- <Slot { ...props } bubblesVirtually={ bubblesVirtually } />
35
+ <BlockSupportSlotContainer
36
+ { ...props }
37
+ bubblesVirtually={ bubblesVirtually }
38
+ Slot={ Slot }
39
+ />
35
40
  </BlockSupportToolsPanel>
36
41
  );
37
42
  }
@@ -132,12 +132,16 @@ $preview-image-height: 140px;
132
132
  border: none;
133
133
  text-align: left;
134
134
  padding: $grid-unit-15 $grid-unit-20;
135
- border-radius: 5px;
135
+ border-radius: 2px;
136
136
  height: auto;
137
137
 
138
138
  &:hover,
139
139
  &:focus {
140
- background-color: $gray-300;
140
+ background-color: $gray-100;
141
+
142
+ .block-editor-link-control__search-item-type {
143
+ background: $white;
144
+ }
141
145
  }
142
146
 
143
147
  // The added specificity is needed to override.
@@ -231,7 +235,7 @@ $preview-image-height: 140px;
231
235
 
232
236
  mark {
233
237
  font-weight: 700;
234
- color: $black;
238
+ color: inherit;
235
239
  background-color: transparent;
236
240
  }
237
241
 
@@ -258,7 +262,7 @@ $preview-image-height: 140px;
258
262
 
259
263
  .block-editor-link-control__search-item-type {
260
264
  display: block;
261
- padding: 3px 8px;
265
+ padding: 3px 6px;
262
266
  margin-left: auto;
263
267
  font-size: 0.9em;
264
268
  background-color: $gray-100;
@@ -407,7 +411,7 @@ $preview-image-height: 140px;
407
411
  }
408
412
  }
409
413
 
410
- // Specificity overide
414
+ // Specificity override
411
415
  .block-editor-link-control__search-results div[role="menu"] > .block-editor-link-control__search-item.block-editor-link-control__search-item {
412
416
  padding: 10px;
413
417
  }
@@ -12,8 +12,6 @@ import { forwardRef } from '@wordpress/element';
12
12
  /**
13
13
  * Internal dependencies
14
14
  */
15
- import { useListViewContext } from './context';
16
- import ListViewBlockSlot from './block-slot';
17
15
  import ListViewBlockSelectButton from './block-select-button';
18
16
  import BlockDraggable from '../block-draggable';
19
17
  import { store as blockEditorStore } from '../../store';
@@ -32,8 +30,6 @@ const ListViewBlockContents = forwardRef(
32
30
  },
33
31
  ref
34
32
  ) => {
35
- const { __experimentalFeatures } = useListViewContext();
36
-
37
33
  const { clientId } = block;
38
34
 
39
35
  const { blockMovingClientId, selectedBlockInBlockEditor } = useSelect(
@@ -61,40 +57,23 @@ const ListViewBlockContents = forwardRef(
61
57
 
62
58
  return (
63
59
  <BlockDraggable clientIds={ [ block.clientId ] }>
64
- { ( { draggable, onDragStart, onDragEnd } ) =>
65
- __experimentalFeatures ? (
66
- <ListViewBlockSlot
67
- ref={ ref }
68
- className={ className }
69
- block={ block }
70
- onToggleExpanded={ onToggleExpanded }
71
- isSelected={ isSelected }
72
- position={ position }
73
- siblingBlockCount={ siblingBlockCount }
74
- level={ level }
75
- draggable={ draggable && __experimentalFeatures }
76
- onDragStart={ onDragStart }
77
- onDragEnd={ onDragEnd }
78
- { ...props }
79
- />
80
- ) : (
81
- <ListViewBlockSelectButton
82
- ref={ ref }
83
- className={ className }
84
- block={ block }
85
- onClick={ onClick }
86
- onToggleExpanded={ onToggleExpanded }
87
- isSelected={ isSelected }
88
- position={ position }
89
- siblingBlockCount={ siblingBlockCount }
90
- level={ level }
91
- draggable={ draggable }
92
- onDragStart={ onDragStart }
93
- onDragEnd={ onDragEnd }
94
- { ...props }
95
- />
96
- )
97
- }
60
+ { ( { draggable, onDragStart, onDragEnd } ) => (
61
+ <ListViewBlockSelectButton
62
+ ref={ ref }
63
+ className={ className }
64
+ block={ block }
65
+ onClick={ onClick }
66
+ onToggleExpanded={ onToggleExpanded }
67
+ isSelected={ isSelected }
68
+ position={ position }
69
+ siblingBlockCount={ siblingBlockCount }
70
+ level={ level }
71
+ draggable={ draggable }
72
+ onDragStart={ onDragStart }
73
+ onDragEnd={ onDragEnd }
74
+ { ...props }
75
+ />
76
+ ) }
98
77
  </BlockDraggable>
99
78
  );
100
79
  }
@@ -9,13 +9,10 @@ import classnames from 'classnames';
9
9
  import {
10
10
  __experimentalTreeGridCell as TreeGridCell,
11
11
  __experimentalTreeGridItem as TreeGridItem,
12
- MenuGroup,
13
- MenuItem,
14
12
  } from '@wordpress/components';
15
- import { __ } from '@wordpress/i18n';
16
13
  import { moreVertical } from '@wordpress/icons';
17
14
  import { useState, useRef, useEffect } from '@wordpress/element';
18
- import { useDispatch, useSelect } from '@wordpress/data';
15
+ import { useDispatch } from '@wordpress/data';
19
16
 
20
17
  /**
21
18
  * Internal dependencies
@@ -49,23 +46,14 @@ export default function ListViewBlock( {
49
46
  const cellRef = useRef( null );
50
47
  const [ isHovered, setIsHovered ] = useState( false );
51
48
  const { clientId } = block;
52
- const blockParents = useSelect(
53
- ( select ) => {
54
- return select( blockEditorStore ).getBlockParents( clientId );
55
- },
56
- [ clientId ]
57
- );
58
49
 
59
- const {
60
- selectBlock: selectEditorBlock,
61
- toggleBlockHighlight,
62
- } = useDispatch( blockEditorStore );
50
+ const { toggleBlockHighlight } = useDispatch( blockEditorStore );
63
51
 
64
52
  const hasSiblings = siblingBlockCount > 0;
65
53
  const hasRenderedMovers = showBlockMovers && hasSiblings;
66
54
  const moverCellClassName = classnames(
67
55
  'block-editor-list-view-block__mover-cell',
68
- { 'is-visible': isHovered }
56
+ { 'is-visible': isHovered || isSelected }
69
57
  );
70
58
  const {
71
59
  __experimentalFeatures: withExperimentalFeatures,
@@ -74,7 +62,7 @@ export default function ListViewBlock( {
74
62
  } = useListViewContext();
75
63
  const listViewBlockSettingsClassName = classnames(
76
64
  'block-editor-list-view-block__menu-cell',
77
- { 'is-visible': isHovered }
65
+ { 'is-visible': isHovered || isSelected }
78
66
  );
79
67
 
80
68
  // If ListView has experimental features related to the Persistent List View,
@@ -90,14 +78,6 @@ export default function ListViewBlock( {
90
78
  }
91
79
  }, [] );
92
80
 
93
- // If ListView has experimental features (such as drag and drop) enabled,
94
- // leave the focus handling as it was before, to avoid accidental regressions.
95
- useEffect( () => {
96
- if ( withExperimentalFeatures && isSelected ) {
97
- cellRef.current.focus();
98
- }
99
- }, [ withExperimentalFeatures, isSelected ] );
100
-
101
81
  const highlightBlock = withExperimentalPersistentListViewFeatures
102
82
  ? toggleBlockHighlight
103
83
  : () => {};
@@ -198,38 +178,13 @@ export default function ListViewBlock( {
198
178
  icon={ moreVertical }
199
179
  toggleProps={ {
200
180
  ref,
181
+ className: 'block-editor-list-view-block__menu',
201
182
  tabIndex,
202
183
  onFocus,
203
184
  } }
204
185
  disableOpenOnArrowDown
205
186
  __experimentalSelectBlock={ onClick }
206
- >
207
- { ( { onClose } ) => (
208
- <MenuGroup>
209
- <MenuItem
210
- onClick={ async () => {
211
- if ( blockParents.length ) {
212
- // If the block to select is inside a dropdown, we need to open the dropdown.
213
- // Otherwise focus won't transfer to the block.
214
- for ( const parent of blockParents ) {
215
- await selectEditorBlock(
216
- parent
217
- );
218
- }
219
- } else {
220
- // If clientId is already selected, it won't be focused (see block-wrapper.js)
221
- // This removes the selection first to ensure the focus will always switch.
222
- await selectEditorBlock( null );
223
- }
224
- await selectEditorBlock( clientId );
225
- onClose();
226
- } }
227
- >
228
- { __( 'Go to block' ) }
229
- </MenuItem>
230
- </MenuGroup>
231
- ) }
232
- </BlockSettingsDropdown>
187
+ />
233
188
  ) }
234
189
  </TreeGridCell>
235
190
  ) }
@@ -26,6 +26,9 @@ export default function ListViewListItem( {
26
26
  children,
27
27
  } ) {
28
28
  const blockType = getBlockType( block.name );
29
+ const blockLabel = blockType
30
+ ? getBlockLabel( blockType, block.attributes )
31
+ : null;
29
32
 
30
33
  return (
31
34
  <div className="block-editor-list-view__list-item">
@@ -38,10 +41,8 @@ export default function ListViewListItem( {
38
41
  ) }
39
42
  onClick={ onClick }
40
43
  >
41
- <BlockIcon icon={ blockType.icon } showColors />
42
- { children
43
- ? children
44
- : getBlockLabel( blockType, block.attributes ) }
44
+ <BlockIcon icon={ blockType?.icon } showColors />
45
+ { children ? children : blockLabel }
45
46
  { isSelected && (
46
47
  <VisuallyHidden as="span">
47
48
  { __( '(selected block)' ) }
@@ -15,10 +15,14 @@
15
15
  // Use position relative for row animation.
16
16
  position: relative;
17
17
 
18
- &.is-selected .block-editor-list-view-block-contents {
18
+ &.is-selected {
19
19
  background: var(--wp-admin-theme-color);
20
+ }
21
+ &.is-selected .block-editor-list-view-block-contents,
22
+ &.is-selected .components-button.has-icon {
20
23
  color: $white;
21
-
24
+ }
25
+ &.is-selected .block-editor-list-view-block-contents {
22
26
  // Hide selection styles while a user is dragging blocks/files etc.
23
27
  .is-dragging-components-draggable & {
24
28
  background: none;
@@ -26,30 +30,31 @@
26
30
  }
27
31
  }
28
32
  &.is-selected .block-editor-list-view-block-contents:focus {
29
- box-shadow:
30
- inset 0 0 0 1px $white,
31
- 0 0 0 var(--wp-admin-border-width-focus) var(--wp-admin-theme-color);
32
-
33
- // Hide focus styles while a user is dragging blocks/files etc.
34
- .is-dragging-components-draggable & {
35
- box-shadow: none;
33
+ &::after {
34
+ box-shadow:
35
+ inset 0 0 0 1px $white,
36
+ 0 0 0 var(--wp-admin-border-width-focus) var(--wp-admin-theme-color);
36
37
  }
37
38
  }
39
+ &.is-selected .block-editor-list-view-block__menu:focus {
40
+ box-shadow: inset 0 0 0 var(--wp-admin-border-width-focus) $white;
41
+ }
38
42
 
43
+ &.is-branch-selected:not(.is-selected) {
44
+ // Lighten a CSS variable without introducing a new SASS variable
45
+ background:
46
+ linear-gradient(transparentize($white, 0.1), transparentize($white, 0.1)),
47
+ linear-gradient(var(--wp-admin-theme-color), var(--wp-admin-theme-color));
48
+ }
39
49
  &.is-branch-selected.is-selected .block-editor-list-view-block-contents {
40
50
  border-radius: 2px 2px 0 0;
41
51
  }
42
-
43
52
  &[aria-expanded="false"] {
44
53
  &.is-branch-selected.is-selected .block-editor-list-view-block-contents {
45
54
  border-radius: 2px;
46
55
  }
47
56
  }
48
57
  &.is-branch-selected:not(.is-selected) .block-editor-list-view-block-contents {
49
- // Lighten a CSS variable without introducing a new SASS variable
50
- background:
51
- linear-gradient(transparentize($white, 0.1), transparentize($white, 0.1)),
52
- linear-gradient(var(--wp-admin-theme-color), var(--wp-admin-theme-color));
53
58
  border-radius: 0;
54
59
  }
55
60
  &.is-branch-selected.is-last-of-selected-branch .block-editor-list-view-block-contents {
@@ -72,19 +77,6 @@
72
77
  position: relative;
73
78
  white-space: nowrap;
74
79
 
75
- &:hover,
76
- &:focus {
77
- box-shadow: inset 0 0 0 var(--wp-admin-border-width-focus) var(--wp-admin-theme-color);
78
-
79
- // Hide hover styles while a user is dragging blocks/files etc.
80
- .is-dragging-components-draggable & {
81
- box-shadow: none;
82
- }
83
- }
84
- &:focus {
85
- z-index: 1;
86
- }
87
-
88
80
  &.is-dropping-before::before {
89
81
  content: "";
90
82
  position: absolute;
@@ -102,6 +94,37 @@
102
94
  }
103
95
  }
104
96
 
97
+ .block-editor-list-view-block-contents:focus {
98
+ box-shadow: none;
99
+
100
+ &::after {
101
+ content: "";
102
+ position: absolute;
103
+ top: 0;
104
+ right: -(24px + 5px); // Icon size + padding.
105
+ bottom: 0;
106
+ left: 0;
107
+ border-radius: inherit;
108
+ box-shadow: inset 0 0 0 var(--wp-admin-border-width-focus) var(--wp-admin-theme-color);
109
+ z-index: 1;
110
+ pointer-events: none;
111
+
112
+ // Hide focus styles while a user is dragging blocks/files etc.
113
+ .is-dragging-components-draggable & {
114
+ box-shadow: none;
115
+ }
116
+ }
117
+ }
118
+ .block-editor-list-view-block__menu:focus {
119
+ box-shadow: inset 0 0 0 var(--wp-admin-border-width-focus) var(--wp-admin-theme-color);
120
+ z-index: 1;
121
+
122
+ // Hide focus styles while a user is dragging blocks/files etc.
123
+ .is-dragging-components-draggable & {
124
+ box-shadow: none;
125
+ }
126
+ }
127
+
105
128
  &.is-visible .block-editor-list-view-block-contents {
106
129
  opacity: 1;
107
130
  @include edit-post__fade-in-animation;
@@ -125,7 +148,7 @@
125
148
  line-height: 0;
126
149
  width: $button-size;
127
150
  opacity: 0;
128
- vertical-align: top;
151
+ vertical-align: middle;
129
152
  @include reduce-motion("transition");
130
153
 
131
154
  // Show on hover, visible, and show above to keep the hit area size.
@@ -146,7 +169,11 @@
146
169
  }
147
170
 
148
171
  .block-editor-list-view-block__menu-cell {
149
- padding-top: $grid-unit-10;
172
+ padding-right: 5px;
173
+
174
+ .components-button.has-icon {
175
+ height: 24px;
176
+ }
150
177
  }
151
178
 
152
179
  .block-editor-list-view-block__mover-cell-alignment-wrapper {
@@ -248,7 +275,6 @@
248
275
  }
249
276
  }
250
277
 
251
- .block-editor-list-view-block-slot__description,
252
278
  .block-editor-list-view-block-select-button__description,
253
279
  .block-editor-list-view-appender__description {
254
280
  display: none;
@@ -76,6 +76,9 @@ export function MediaPlaceholder( {
76
76
  onFilesPreUpload = noop,
77
77
  onHTMLDrop = noop,
78
78
  children,
79
+ mediaLibraryButton,
80
+ placeholder,
81
+ style,
79
82
  } ) {
80
83
  const mediaUpload = useSelect( ( select ) => {
81
84
  const { getSettings } = select( blockEditorStore );
@@ -178,7 +181,7 @@ export function MediaPlaceholder( {
178
181
  onFilesUpload( event.target.files );
179
182
  };
180
183
 
181
- const renderPlaceholder = ( content ) => {
184
+ const defaultRenderPlaceholder = ( content ) => {
182
185
  let { instructions, title } = labels;
183
186
 
184
187
  if ( ! mediaUpload && ! onSelectURL ) {
@@ -246,12 +249,14 @@ export function MediaPlaceholder( {
246
249
  notices={ notices }
247
250
  onDoubleClick={ onDoubleClick }
248
251
  preview={ mediaPreview }
252
+ style={ style }
249
253
  >
250
254
  { content }
251
255
  { children }
252
256
  </Placeholder>
253
257
  );
254
258
  };
259
+ const renderPlaceholder = placeholder ?? defaultRenderPlaceholder;
255
260
 
256
261
  const renderDropZone = () => {
257
262
  if ( disableDropZone ) {
@@ -304,7 +309,20 @@ export function MediaPlaceholder( {
304
309
  };
305
310
 
306
311
  const renderMediaUploadChecked = () => {
307
- const mediaLibraryButton = (
312
+ const defaultButton = ( { open } ) => {
313
+ return (
314
+ <Button
315
+ variant="tertiary"
316
+ onClick={ () => {
317
+ open();
318
+ } }
319
+ >
320
+ { __( 'Media Library' ) }
321
+ </Button>
322
+ );
323
+ };
324
+ const libraryButton = mediaLibraryButton ?? defaultButton;
325
+ const uploadMediaLibraryButton = (
308
326
  <MediaUpload
309
327
  addToGallery={ addToGallery }
310
328
  gallery={ multiple && onlyAllowsImages() }
@@ -316,18 +334,7 @@ export function MediaPlaceholder( {
316
334
  ? value.map( ( { id } ) => id )
317
335
  : value.id
318
336
  }
319
- render={ ( { open } ) => {
320
- return (
321
- <Button
322
- variant="tertiary"
323
- onClick={ () => {
324
- open();
325
- } }
326
- >
327
- { __( 'Media Library' ) }
328
- </Button>
329
- );
330
- } }
337
+ render={ libraryButton }
331
338
  />
332
339
  );
333
340
 
@@ -352,7 +359,7 @@ export function MediaPlaceholder( {
352
359
  >
353
360
  { __( 'Upload' ) }
354
361
  </Button>
355
- { mediaLibraryButton }
362
+ { uploadMediaLibraryButton }
356
363
  { renderUrlSelectionUI() }
357
364
  { renderCancelLink() }
358
365
  </>
@@ -380,7 +387,7 @@ export function MediaPlaceholder( {
380
387
  >
381
388
  { __( 'Upload' ) }
382
389
  </FormFileUpload>
383
- { mediaLibraryButton }
390
+ { uploadMediaLibraryButton }
384
391
  { renderUrlSelectionUI() }
385
392
  { renderCancelLink() }
386
393
  </>
@@ -388,7 +395,7 @@ export function MediaPlaceholder( {
388
395
  return renderPlaceholder( content );
389
396
  }
390
397
 
391
- return renderPlaceholder( mediaLibraryButton );
398
+ return renderPlaceholder( uploadMediaLibraryButton );
392
399
  };
393
400
 
394
401
  if ( dropZoneUIOnly || disableMediaButtons ) {
@@ -76,3 +76,10 @@ Removes a media replace notice.
76
76
 
77
77
  - Type: `func`
78
78
  - Required: No
79
+
80
+ ### children
81
+
82
+ - Type: `Element`
83
+ - Required: No
84
+
85
+ If passed, children are rendered inside the dropdown.
@@ -42,6 +42,7 @@ const MediaReplaceFlow = ( {
42
42
  name = __( 'Replace' ),
43
43
  createNotice,
44
44
  removeNotice,
45
+ children,
45
46
  } ) => {
46
47
  const [ mediaURLValue, setMediaURLValue ] = useState( mediaURL );
47
48
  const mediaUpload = useSelect( ( select ) => {
@@ -161,6 +162,7 @@ const MediaReplaceFlow = ( {
161
162
  } }
162
163
  />
163
164
  </MediaUploadCheck>
165
+ { children }
164
166
  </NavigableMenu>
165
167
  { onSelectURL && (
166
168
  // eslint-disable-next-line jsx-a11y/no-noninteractive-element-interactions