@wordpress/block-editor 10.2.0 → 10.3.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 (285) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/README.md +41 -0
  3. package/build/components/block-draggable/draggable-chip.js +4 -2
  4. package/build/components/block-draggable/draggable-chip.js.map +1 -1
  5. package/build/components/block-inspector/index.js +4 -4
  6. package/build/components/block-inspector/index.js.map +1 -1
  7. package/build/components/block-list/block-list-compact.native.js +1 -0
  8. package/build/components/block-list/block-list-compact.native.js.map +1 -1
  9. package/build/components/block-list/block.js +72 -14
  10. package/build/components/block-list/block.js.map +1 -1
  11. package/build/components/block-list/block.native.js +79 -12
  12. package/build/components/block-list/block.native.js.map +1 -1
  13. package/build/components/block-list/use-in-between-inserter.js +7 -23
  14. package/build/components/block-list/use-in-between-inserter.js.map +1 -1
  15. package/build/components/block-lock/modal.js +9 -6
  16. package/build/components/block-lock/modal.js.map +1 -1
  17. package/build/components/block-parent-selector/index.js +3 -3
  18. package/build/components/block-parent-selector/index.js.map +1 -1
  19. package/build/components/block-patterns-list/index.js +5 -4
  20. package/build/components/block-patterns-list/index.js.map +1 -1
  21. package/build/components/block-popover/drop-zone.js +85 -0
  22. package/build/components/block-popover/drop-zone.js.map +1 -0
  23. package/build/components/block-popover/index.js +2 -1
  24. package/build/components/block-popover/index.js.map +1 -1
  25. package/build/components/block-preview/auto.js +2 -2
  26. package/build/components/block-preview/auto.js.map +1 -1
  27. package/build/components/block-preview/index.js +6 -9
  28. package/build/components/block-preview/index.js.map +1 -1
  29. package/build/components/block-preview/live.js +3 -7
  30. package/build/components/block-preview/live.js.map +1 -1
  31. package/build/components/block-selection-clearer/index.js +9 -1
  32. package/build/components/block-selection-clearer/index.js.map +1 -1
  33. package/build/components/block-settings-menu/block-settings-dropdown.js +17 -11
  34. package/build/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
  35. package/build/components/block-styles/index.js +18 -42
  36. package/build/components/block-styles/index.js.map +1 -1
  37. package/build/components/block-toolbar/index.js +4 -4
  38. package/build/components/block-toolbar/index.js.map +1 -1
  39. package/build/components/block-tools/back-compat.js +2 -1
  40. package/build/components/block-tools/back-compat.js.map +1 -1
  41. package/build/components/block-tools/insertion-point.js +50 -20
  42. package/build/components/block-tools/insertion-point.js.map +1 -1
  43. package/build/components/block-tools/selected-block-popover.js +15 -3
  44. package/build/components/block-tools/selected-block-popover.js.map +1 -1
  45. package/build/components/colors-gradients/control.js +1 -1
  46. package/build/components/colors-gradients/control.js.map +1 -1
  47. package/build/components/colors-gradients/panel-color-gradient-settings.js +2 -2
  48. package/build/components/colors-gradients/panel-color-gradient-settings.js.map +1 -1
  49. package/build/components/font-sizes/fluid-utils.js +256 -0
  50. package/build/components/font-sizes/fluid-utils.js.map +1 -0
  51. package/build/components/font-sizes/index.js +8 -0
  52. package/build/components/font-sizes/index.js.map +1 -1
  53. package/build/components/index.js +0 -9
  54. package/build/components/index.js.map +1 -1
  55. package/build/components/inner-blocks/use-inner-block-template-sync.js +3 -2
  56. package/build/components/inner-blocks/use-inner-block-template-sync.js.map +1 -1
  57. package/build/components/inserter/block-patterns-tab.js +151 -78
  58. package/build/components/inserter/block-patterns-tab.js.map +1 -1
  59. package/build/components/inserter/menu.js +14 -3
  60. package/build/components/inserter/menu.js.map +1 -1
  61. package/build/components/inserter-draggable-blocks/index.js +4 -2
  62. package/build/components/inserter-draggable-blocks/index.js.map +1 -1
  63. package/build/components/list-view/use-list-view-drop-zone.js +1 -14
  64. package/build/components/list-view/use-list-view-drop-zone.js.map +1 -1
  65. package/build/components/preview-options/index.js +2 -3
  66. package/build/components/preview-options/index.js.map +1 -1
  67. package/build/components/spacing-sizes-control/spacing-input-control.js +35 -5
  68. package/build/components/spacing-sizes-control/spacing-input-control.js.map +1 -1
  69. package/build/components/use-block-drop-zone/index.js +98 -57
  70. package/build/components/use-block-drop-zone/index.js.map +1 -1
  71. package/build/components/use-on-block-drop/index.js +12 -12
  72. package/build/components/use-on-block-drop/index.js.map +1 -1
  73. package/build/components/use-on-block-drop/types.js +6 -0
  74. package/build/components/use-on-block-drop/types.js.map +1 -0
  75. package/build/hooks/align.js +1 -3
  76. package/build/hooks/align.js.map +1 -1
  77. package/build/hooks/align.native.js +1 -7
  78. package/build/hooks/align.native.js.map +1 -1
  79. package/build/hooks/font-size.js +60 -0
  80. package/build/hooks/font-size.js.map +1 -1
  81. package/build/hooks/margin.js +6 -5
  82. package/build/hooks/margin.js.map +1 -1
  83. package/build/hooks/padding.js +2 -1
  84. package/build/hooks/padding.js.map +1 -1
  85. package/build/hooks/style.js +126 -4
  86. package/build/hooks/style.js.map +1 -1
  87. package/build/hooks/use-typography-props.js +17 -3
  88. package/build/hooks/use-typography-props.js.map +1 -1
  89. package/build/hooks/utils.js +1 -1
  90. package/build/hooks/utils.js.map +1 -1
  91. package/build/store/actions.js +59 -45
  92. package/build/store/actions.js.map +1 -1
  93. package/build/store/defaults.js +3 -0
  94. package/build/store/defaults.js.map +1 -1
  95. package/build/store/reducer.js +31 -15
  96. package/build/store/reducer.js.map +1 -1
  97. package/build/utils/math.js +14 -0
  98. package/build/utils/math.js.map +1 -1
  99. package/build/utils/pre-parse-patterns.js +19 -2
  100. package/build/utils/pre-parse-patterns.js.map +1 -1
  101. package/build-module/components/block-draggable/draggable-chip.js +7 -3
  102. package/build-module/components/block-draggable/draggable-chip.js.map +1 -1
  103. package/build-module/components/block-inspector/index.js +4 -4
  104. package/build-module/components/block-inspector/index.js.map +1 -1
  105. package/build-module/components/block-list/block-list-compact.native.js +1 -0
  106. package/build-module/components/block-list/block-list-compact.native.js.map +1 -1
  107. package/build-module/components/block-list/block.js +72 -14
  108. package/build-module/components/block-list/block.js.map +1 -1
  109. package/build-module/components/block-list/block.native.js +80 -13
  110. package/build-module/components/block-list/block.native.js.map +1 -1
  111. package/build-module/components/block-list/use-in-between-inserter.js +8 -24
  112. package/build-module/components/block-list/use-in-between-inserter.js.map +1 -1
  113. package/build-module/components/block-lock/modal.js +10 -8
  114. package/build-module/components/block-lock/modal.js.map +1 -1
  115. package/build-module/components/block-parent-selector/index.js +3 -3
  116. package/build-module/components/block-parent-selector/index.js.map +1 -1
  117. package/build-module/components/block-patterns-list/index.js +5 -4
  118. package/build-module/components/block-patterns-list/index.js.map +1 -1
  119. package/build-module/components/block-popover/drop-zone.js +70 -0
  120. package/build-module/components/block-popover/drop-zone.js.map +1 -0
  121. package/build-module/components/block-popover/index.js +2 -1
  122. package/build-module/components/block-popover/index.js.map +1 -1
  123. package/build-module/components/block-preview/auto.js +1 -1
  124. package/build-module/components/block-preview/auto.js.map +1 -1
  125. package/build-module/components/block-preview/index.js +6 -9
  126. package/build-module/components/block-preview/index.js.map +1 -1
  127. package/build-module/components/block-preview/live.js +3 -6
  128. package/build-module/components/block-preview/live.js.map +1 -1
  129. package/build-module/components/block-selection-clearer/index.js +9 -1
  130. package/build-module/components/block-selection-clearer/index.js.map +1 -1
  131. package/build-module/components/block-settings-menu/block-settings-dropdown.js +18 -12
  132. package/build-module/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
  133. package/build-module/components/block-styles/index.js +19 -44
  134. package/build-module/components/block-styles/index.js.map +1 -1
  135. package/build-module/components/block-toolbar/index.js +4 -4
  136. package/build-module/components/block-toolbar/index.js.map +1 -1
  137. package/build-module/components/block-tools/back-compat.js +2 -1
  138. package/build-module/components/block-tools/back-compat.js.map +1 -1
  139. package/build-module/components/block-tools/insertion-point.js +48 -20
  140. package/build-module/components/block-tools/insertion-point.js.map +1 -1
  141. package/build-module/components/block-tools/selected-block-popover.js +15 -3
  142. package/build-module/components/block-tools/selected-block-popover.js.map +1 -1
  143. package/build-module/components/colors-gradients/control.js +2 -2
  144. package/build-module/components/colors-gradients/control.js.map +1 -1
  145. package/build-module/components/colors-gradients/panel-color-gradient-settings.js +3 -3
  146. package/build-module/components/colors-gradients/panel-color-gradient-settings.js.map +1 -1
  147. package/build-module/components/font-sizes/fluid-utils.js +245 -0
  148. package/build-module/components/font-sizes/fluid-utils.js.map +1 -0
  149. package/build-module/components/font-sizes/index.js +1 -0
  150. package/build-module/components/font-sizes/index.js.map +1 -1
  151. package/build-module/components/index.js +0 -1
  152. package/build-module/components/index.js.map +1 -1
  153. package/build-module/components/inner-blocks/use-inner-block-template-sync.js +3 -2
  154. package/build-module/components/inner-blocks/use-inner-block-template-sync.js.map +1 -1
  155. package/build-module/components/inserter/block-patterns-tab.js +148 -81
  156. package/build-module/components/inserter/block-patterns-tab.js.map +1 -1
  157. package/build-module/components/inserter/menu.js +10 -3
  158. package/build-module/components/inserter/menu.js.map +1 -1
  159. package/build-module/components/inserter-draggable-blocks/index.js +4 -2
  160. package/build-module/components/inserter-draggable-blocks/index.js.map +1 -1
  161. package/build-module/components/list-view/use-list-view-drop-zone.js +1 -14
  162. package/build-module/components/list-view/use-list-view-drop-zone.js.map +1 -1
  163. package/build-module/components/preview-options/index.js +2 -3
  164. package/build-module/components/preview-options/index.js.map +1 -1
  165. package/build-module/components/spacing-sizes-control/spacing-input-control.js +34 -5
  166. package/build-module/components/spacing-sizes-control/spacing-input-control.js.map +1 -1
  167. package/build-module/components/use-block-drop-zone/index.js +98 -58
  168. package/build-module/components/use-block-drop-zone/index.js.map +1 -1
  169. package/build-module/components/use-on-block-drop/index.js +12 -12
  170. package/build-module/components/use-on-block-drop/index.js.map +1 -1
  171. package/build-module/components/use-on-block-drop/types.js +2 -0
  172. package/build-module/components/use-on-block-drop/types.js.map +1 -0
  173. package/build-module/hooks/align.js +1 -2
  174. package/build-module/hooks/align.js.map +1 -1
  175. package/build-module/hooks/align.native.js +1 -6
  176. package/build-module/hooks/align.native.js.map +1 -1
  177. package/build-module/hooks/font-size.js +59 -1
  178. package/build-module/hooks/font-size.js.map +1 -1
  179. package/build-module/hooks/margin.js +6 -5
  180. package/build-module/hooks/margin.js.map +1 -1
  181. package/build-module/hooks/padding.js +2 -1
  182. package/build-module/hooks/padding.js.map +1 -1
  183. package/build-module/hooks/style.js +124 -3
  184. package/build-module/hooks/style.js.map +1 -1
  185. package/build-module/hooks/use-typography-props.js +17 -4
  186. package/build-module/hooks/use-typography-props.js.map +1 -1
  187. package/build-module/hooks/utils.js +2 -2
  188. package/build-module/hooks/utils.js.map +1 -1
  189. package/build-module/store/actions.js +55 -42
  190. package/build-module/store/actions.js.map +1 -1
  191. package/build-module/store/defaults.js +3 -0
  192. package/build-module/store/defaults.js.map +1 -1
  193. package/build-module/store/reducer.js +32 -16
  194. package/build-module/store/reducer.js.map +1 -1
  195. package/build-module/utils/math.js +12 -0
  196. package/build-module/utils/math.js.map +1 -1
  197. package/build-module/utils/pre-parse-patterns.js +19 -2
  198. package/build-module/utils/pre-parse-patterns.js.map +1 -1
  199. package/build-style/style-rtl.css +243 -144
  200. package/build-style/style.css +243 -144
  201. package/package.json +28 -28
  202. package/src/components/block-breadcrumb/test/index.js +1 -1
  203. package/src/components/block-draggable/draggable-chip.js +4 -2
  204. package/src/components/block-inspector/index.js +8 -7
  205. package/src/components/block-list/block-list-compact.native.js +1 -0
  206. package/src/components/block-list/block.js +111 -7
  207. package/src/components/block-list/block.native.js +123 -9
  208. package/src/components/block-list/style.scss +93 -126
  209. package/src/components/block-list/use-in-between-inserter.js +8 -19
  210. package/src/components/block-lock/modal.js +12 -7
  211. package/src/components/block-mover/style.scss +0 -1
  212. package/src/components/block-parent-selector/index.js +3 -3
  213. package/src/components/block-patterns-list/index.js +9 -5
  214. package/src/components/block-patterns-list/style.scss +7 -3
  215. package/src/components/block-popover/README.md +8 -0
  216. package/src/components/block-popover/drop-zone.js +63 -0
  217. package/src/components/block-popover/index.js +2 -1
  218. package/src/components/block-popover/style.scss +17 -1
  219. package/src/components/block-preview/auto.js +1 -1
  220. package/src/components/block-preview/index.js +7 -8
  221. package/src/components/block-preview/live.js +2 -7
  222. package/src/components/block-preview/test/index.js +1 -7
  223. package/src/components/block-selection-clearer/index.js +7 -2
  224. package/src/components/block-selection-clearer/test/index.js +118 -0
  225. package/src/components/block-settings-menu/block-settings-dropdown.js +25 -11
  226. package/src/components/block-settings-menu/test/block-mode-toggle.js +17 -17
  227. package/src/components/block-styles/index.js +26 -49
  228. package/src/components/block-switcher/test/index.js +2 -2
  229. package/src/components/block-toolbar/index.js +4 -6
  230. package/src/components/block-toolbar/style.scss +38 -14
  231. package/src/components/block-tools/back-compat.js +1 -0
  232. package/src/components/block-tools/insertion-point.js +42 -17
  233. package/src/components/block-tools/selected-block-popover.js +14 -1
  234. package/src/components/button-block-appender/style.scss +4 -2
  235. package/src/components/color-palette/test/__snapshots__/control.js.snap +32 -52
  236. package/src/components/color-palette/test/control.js +11 -15
  237. package/src/components/colors-gradients/control.js +2 -2
  238. package/src/components/colors-gradients/panel-color-gradient-settings.js +3 -4
  239. package/src/components/colors-gradients/test/control.js +49 -77
  240. package/src/components/font-sizes/fluid-utils.js +296 -0
  241. package/src/components/font-sizes/index.js +1 -0
  242. package/src/components/font-sizes/test/fluid-utils.js +168 -0
  243. package/src/components/image-size-control/test/index.js +47 -60
  244. package/src/components/index.js +0 -1
  245. package/src/components/inner-blocks/use-inner-block-template-sync.js +3 -2
  246. package/src/components/inserter/block-patterns-tab.js +232 -98
  247. package/src/components/inserter/menu.js +15 -2
  248. package/src/components/inserter/style.scss +94 -9
  249. package/src/components/inserter/test/reusable-blocks-tab.js +6 -6
  250. package/src/components/inserter-draggable-blocks/index.js +12 -2
  251. package/src/components/inserter-list-item/style.scss +20 -1
  252. package/src/components/link-control/test/index.js +1 -1
  253. package/src/components/list-view/use-list-view-drop-zone.js +4 -18
  254. package/src/components/panel-color-settings/test/index.js +4 -4
  255. package/src/components/preview-options/index.js +2 -2
  256. package/src/components/preview-options/style.scss +1 -1
  257. package/src/components/provider/test/use-block-sync.js +131 -165
  258. package/src/components/responsive-block-control/test/index.js +4 -4
  259. package/src/components/spacing-sizes-control/spacing-input-control.js +16 -2
  260. package/src/components/spacing-sizes-control/style.scss +26 -19
  261. package/src/components/use-block-drop-zone/index.js +136 -79
  262. package/src/components/use-block-drop-zone/test/index.js +333 -81
  263. package/src/components/use-on-block-drop/index.js +11 -12
  264. package/src/components/use-on-block-drop/types.ts +1 -0
  265. package/src/hooks/align.js +3 -2
  266. package/src/hooks/align.native.js +5 -8
  267. package/src/hooks/font-size.js +75 -0
  268. package/src/hooks/margin.js +5 -4
  269. package/src/hooks/padding.js +1 -0
  270. package/src/hooks/style.js +122 -3
  271. package/src/hooks/test/style.js +206 -1
  272. package/src/hooks/test/use-typography-props.js +22 -0
  273. package/src/hooks/use-typography-props.js +18 -3
  274. package/src/hooks/utils.js +6 -2
  275. package/src/store/actions.js +20 -12
  276. package/src/store/defaults.js +3 -0
  277. package/src/store/reducer.js +31 -24
  278. package/src/store/test/actions.js +0 -9
  279. package/src/utils/math.js +17 -0
  280. package/src/utils/pre-parse-patterns.js +12 -7
  281. package/build/components/inserter/pattern-panel.js +0 -87
  282. package/build/components/inserter/pattern-panel.js.map +0 -1
  283. package/build-module/components/inserter/pattern-panel.js +0 -74
  284. package/build-module/components/inserter/pattern-panel.js.map +0 -1
  285. package/src/components/inserter/pattern-panel.js +0 -93
@@ -17,14 +17,15 @@ import { useReducedMotion } from '@wordpress/compose';
17
17
  import Inserter from '../inserter';
18
18
  import { store as blockEditorStore } from '../../store';
19
19
  import BlockPopoverInbetween from '../block-popover/inbetween';
20
+ import BlockDropZonePopover from '../block-popover/drop-zone';
20
21
 
21
22
  export const InsertionPointOpenRef = createContext();
22
23
 
23
- function InsertionPointPopover( {
24
+ function InbetweenInsertionPointPopover( {
24
25
  __unstablePopoverSlot,
25
26
  __unstableContentRef,
26
27
  } ) {
27
- const { selectBlock, hideInsertionPoint } = useDispatch( blockEditorStore );
28
+ const { selectBlock } = useDispatch( blockEditorStore );
28
29
  const openRef = useContext( InsertionPointOpenRef );
29
30
  const ref = useRef();
30
31
  const {
@@ -33,6 +34,8 @@ function InsertionPointPopover( {
33
34
  nextClientId,
34
35
  rootClientId,
35
36
  isInserterShown,
37
+ isDistractionFree,
38
+ isNavigationMode,
36
39
  } = useSelect( ( select ) => {
37
40
  const {
38
41
  getBlockOrder,
@@ -41,6 +44,8 @@ function InsertionPointPopover( {
41
44
  isBlockBeingDragged,
42
45
  getPreviousBlockClientId,
43
46
  getNextBlockClientId,
47
+ getSettings,
48
+ isNavigationMode: _isNavigationMode,
44
49
  } = select( blockEditorStore );
45
50
  const insertionPoint = getBlockInsertionPoint();
46
51
  const order = getBlockOrder( insertionPoint.rootClientId );
@@ -60,6 +65,8 @@ function InsertionPointPopover( {
60
65
  _nextClientId = getNextBlockClientId( _nextClientId );
61
66
  }
62
67
 
68
+ const settings = getSettings();
69
+
63
70
  return {
64
71
  previousClientId: _previousClientId,
65
72
  nextClientId: _nextClientId,
@@ -67,6 +74,8 @@ function InsertionPointPopover( {
67
74
  getBlockListSettings( insertionPoint.rootClientId )
68
75
  ?.orientation || 'vertical',
69
76
  rootClientId: insertionPoint.rootClientId,
77
+ isNavigationMode: _isNavigationMode(),
78
+ isDistractionFree: settings.isDistractionFree,
70
79
  isInserterShown: insertionPoint?.__unstableWithInserter,
71
80
  };
72
81
  }, [] );
@@ -88,14 +97,6 @@ function InsertionPointPopover( {
88
97
  }
89
98
  }
90
99
 
91
- function maybeHideInserterPoint( event ) {
92
- // Only hide the inserter if it's triggered on the wrapper,
93
- // and the inserter is not open.
94
- if ( event.target === ref.current && ! openRef.current ) {
95
- hideInsertionPoint();
96
- }
97
- }
98
-
99
100
  // Define animation variants for the line element.
100
101
  const horizontalLine = {
101
102
  start: {
@@ -149,13 +150,13 @@ function InsertionPointPopover( {
149
150
  ...( ! isVertical ? horizontalLine.rest : verticalLine.rest ),
150
151
  opacity: 1,
151
152
  borderRadius: '2px',
152
- transition: { delay: isInserterShown ? 0.1 : 0, type: 'tween' },
153
+ transition: { delay: isInserterShown ? 0.5 : 0, type: 'tween' },
153
154
  },
154
155
  hover: {
155
156
  ...( ! isVertical ? horizontalLine.hover : verticalLine.hover ),
156
157
  opacity: 1,
157
158
  borderRadius: '2px',
158
- transition: { delay: 0.1, type: 'tween' },
159
+ transition: { delay: 0.5, type: 'tween' },
159
160
  },
160
161
  };
161
162
 
@@ -165,10 +166,14 @@ function InsertionPointPopover( {
165
166
  },
166
167
  rest: {
167
168
  scale: 1,
168
- transition: { type: 'tween' },
169
+ transition: { delay: 0.4, type: 'tween' },
169
170
  },
170
171
  };
171
172
 
173
+ if ( isDistractionFree && ! isNavigationMode ) {
174
+ return null;
175
+ }
176
+
172
177
  const className = classnames(
173
178
  'block-editor-block-list__insertion-point',
174
179
  'is-' + orientation
@@ -195,7 +200,6 @@ function InsertionPointPopover( {
195
200
  className={ classnames( className, {
196
201
  'is-with-inserter': isInserterShown,
197
202
  } ) }
198
- onHoverEnd={ maybeHideInserterPoint }
199
203
  >
200
204
  <motion.div
201
205
  variants={ lineVariants }
@@ -229,9 +233,30 @@ function InsertionPointPopover( {
229
233
  }
230
234
 
231
235
  export default function InsertionPoint( props ) {
232
- const isVisible = useSelect( ( select ) => {
233
- return select( blockEditorStore ).isBlockInsertionPointVisible();
236
+ const { insertionPoint, isVisible } = useSelect( ( select ) => {
237
+ const { getBlockInsertionPoint, isBlockInsertionPointVisible } =
238
+ select( blockEditorStore );
239
+ return {
240
+ insertionPoint: getBlockInsertionPoint(),
241
+ isVisible: isBlockInsertionPointVisible(),
242
+ };
234
243
  }, [] );
235
244
 
236
- return isVisible && <InsertionPointPopover { ...props } />;
245
+ if ( ! isVisible ) {
246
+ return null;
247
+ }
248
+
249
+ /**
250
+ * Render a popover that overlays the block when the desired operation is to replace it.
251
+ * Otherwise, render a popover in between blocks for the indication of inserting between them.
252
+ */
253
+ return insertionPoint.operation === 'replace' ? (
254
+ <BlockDropZonePopover
255
+ // Force remount to trigger the animation.
256
+ key={ `${ insertionPoint.rootClientId }-${ insertionPoint.index }` }
257
+ { ...props }
258
+ />
259
+ ) : (
260
+ <InbetweenInsertionPointPopover { ...props } />
261
+ );
237
262
  }
@@ -36,6 +36,7 @@ function selector( select ) {
36
36
  isMultiSelecting: isMultiSelecting(),
37
37
  isTyping: isTyping(),
38
38
  hasFixedToolbar: getSettings().hasFixedToolbar,
39
+ isDistractionFree: getSettings().isDistractionFree,
39
40
  lastClientId: hasMultiSelection()
40
41
  ? getLastMultiSelectedBlockClientId()
41
42
  : null,
@@ -46,6 +47,7 @@ function SelectedBlockPopover( {
46
47
  clientId,
47
48
  rootClientId,
48
49
  isEmptyDefaultBlock,
50
+ showContents, // we may need to mount an empty popover because we reuse
49
51
  capturingClientId,
50
52
  __unstablePopoverSlot,
51
53
  __unstableContentRef,
@@ -55,6 +57,7 @@ function SelectedBlockPopover( {
55
57
  isMultiSelecting,
56
58
  isTyping,
57
59
  hasFixedToolbar,
60
+ isDistractionFree,
58
61
  lastClientId,
59
62
  } = useSelect( selector, [] );
60
63
  const isInsertionPointVisible = useSelect(
@@ -94,6 +97,7 @@ function SelectedBlockPopover( {
94
97
  editorMode === 'edit' &&
95
98
  ! shouldShowContextualToolbar &&
96
99
  ! hasFixedToolbar &&
100
+ ! isDistractionFree &&
97
101
  ! isEmptyDefaultBlock;
98
102
 
99
103
  useShortcut(
@@ -136,7 +140,7 @@ function SelectedBlockPopover( {
136
140
  resize={ false }
137
141
  { ...popoverProps }
138
142
  >
139
- { shouldShowContextualToolbar && (
143
+ { shouldShowContextualToolbar && showContents && (
140
144
  <BlockContextualToolbar
141
145
  // If the toolbar is being shown because of being forced
142
146
  // it should focus the toolbar right after the mount.
@@ -169,6 +173,8 @@ function wrapperSelector( select ) {
169
173
  getBlockRootClientId,
170
174
  getBlock,
171
175
  getBlockParents,
176
+ getSettings,
177
+ isNavigationMode: _isNavigationMode,
172
178
  __experimentalGetBlockListSettingsForBlocks,
173
179
  } = select( blockEditorStore );
174
180
 
@@ -195,10 +201,14 @@ function wrapperSelector( select ) {
195
201
  ?.__experimentalCaptureToolbars
196
202
  );
197
203
 
204
+ const settings = getSettings();
205
+
198
206
  return {
199
207
  clientId,
200
208
  rootClientId: getBlockRootClientId( clientId ),
201
209
  name,
210
+ isDistractionFree: settings.isDistractionFree,
211
+ isNavigationMode: _isNavigationMode(),
202
212
  isEmptyDefaultBlock:
203
213
  name && isUnmodifiedDefaultBlock( { name, attributes } ),
204
214
  capturingClientId,
@@ -221,6 +231,8 @@ export default function WrappedBlockPopover( {
221
231
  name,
222
232
  isEmptyDefaultBlock,
223
233
  capturingClientId,
234
+ isDistractionFree,
235
+ isNavigationMode,
224
236
  } = selected;
225
237
 
226
238
  if ( ! name ) {
@@ -232,6 +244,7 @@ export default function WrappedBlockPopover( {
232
244
  clientId={ clientId }
233
245
  rootClientId={ rootClientId }
234
246
  isEmptyDefaultBlock={ isEmptyDefaultBlock }
247
+ showContents={ ! isDistractionFree || isNavigationMode }
235
248
  capturingClientId={ capturingClientId }
236
249
  __unstablePopoverSlot={ __unstablePopoverSlot }
237
250
  __unstableContentRef={ __unstableContentRef }
@@ -36,8 +36,9 @@
36
36
  .block-list-appender:only-child {
37
37
  .is-layout-constrained.block-editor-block-list__block:not(.is-selected) > &,
38
38
  .is-layout-flow.block-editor-block-list__block:not(.is-selected) > &,
39
- .is-layout-constrained.block-editor-block-list__block:not(.is-selected) > .block-editor-block-list__layout > &,
40
- .is-layout-flow.block-editor-block-list__block:not(.is-selected) > .block-editor-block-list__layout > & {
39
+ // Legacy groups have an inner container so need to be targeted separately
40
+ .is-layout-constrained.block-editor-block-list__block:not(.is-selected) > .wp-block-group__inner-container > &,
41
+ .is-layout-flow.block-editor-block-list__block:not(.is-selected) > .wp-block-group__inner-container > & {
41
42
  pointer-events: none;
42
43
 
43
44
  &::after {
@@ -48,6 +49,7 @@
48
49
  bottom: 0;
49
50
  left: 0;
50
51
  pointer-events: none;
52
+ border: $border-width dashed currentColor;
51
53
  @include placeholder-style();
52
54
  }
53
55
 
@@ -118,67 +118,61 @@ exports[`ColorPaletteControl matches the snapshot 1`] = `
118
118
  }
119
119
 
120
120
  <div
121
- className="components-base-control block-editor-color-gradient-control emotion-0 emotion-1"
121
+ class="components-base-control block-editor-color-gradient-control emotion-0 emotion-1"
122
122
  >
123
123
  <div
124
- className="components-base-control__field emotion-2 emotion-3"
124
+ class="components-base-control__field emotion-2 emotion-3"
125
125
  >
126
126
  <fieldset
127
- className="block-editor-color-gradient-control__fieldset"
127
+ class="block-editor-color-gradient-control__fieldset"
128
128
  >
129
129
  <div
130
- className="components-flex components-h-stack components-v-stack emotion-4 emotion-5"
131
- data-wp-c16t={true}
130
+ class="components-flex components-h-stack components-v-stack emotion-4 emotion-5"
131
+ data-wp-c16t="true"
132
132
  data-wp-component="VStack"
133
133
  >
134
134
  <legend>
135
135
  <div
136
- className="block-editor-color-gradient-control__color-indicator"
136
+ class="block-editor-color-gradient-control__color-indicator"
137
137
  >
138
138
  <span
139
- className="components-base-control__label emotion-6 emotion-7"
139
+ class="components-base-control__label emotion-6 emotion-7"
140
140
  >
141
141
  Test Color
142
142
  </span>
143
143
  </div>
144
144
  </legend>
145
145
  <div
146
- className="block-editor-color-gradient-control__panel"
146
+ class="block-editor-color-gradient-control__panel"
147
147
  >
148
148
  <div
149
- className="components-flex components-h-stack components-v-stack emotion-8 emotion-5"
150
- data-wp-c16t={true}
149
+ class="components-flex components-h-stack components-v-stack emotion-8 emotion-5"
150
+ data-wp-c16t="true"
151
151
  data-wp-component="VStack"
152
152
  >
153
153
  <div
154
- className="components-dropdown"
155
- tabIndex="-1"
154
+ class="components-dropdown"
155
+ tabindex="-1"
156
156
  >
157
157
  <button
158
- aria-expanded={false}
158
+ aria-expanded="false"
159
159
  aria-haspopup="true"
160
160
  aria-label="Custom color picker. The currently selected color is called \\"red\\" and has a value of \\"f00\\"."
161
- className="components-flex components-color-palette__custom-color emotion-10 emotion-5"
162
- data-wp-c16t={true}
161
+ class="components-flex components-color-palette__custom-color emotion-10 emotion-5"
162
+ data-wp-c16t="true"
163
163
  data-wp-component="Flex"
164
- onClick={[Function]}
165
- style={
166
- Object {
167
- "background": "#f00",
168
- "color": "#000",
169
- }
170
- }
164
+ style="background: rgb(255, 0, 0); color: rgb(0, 0, 0);"
171
165
  >
172
166
  <span
173
- className="components-truncate components-flex-item components-color-palette__custom-color-name emotion-5 emotion-13 emotion-5"
174
- data-wp-c16t={true}
167
+ class="components-truncate components-flex-item components-color-palette__custom-color-name emotion-5 emotion-13 emotion-5"
168
+ data-wp-c16t="true"
175
169
  data-wp-component="FlexItem"
176
170
  >
177
171
  red
178
172
  </span>
179
173
  <span
180
- className="components-flex-item components-color-palette__custom-color-value emotion-15 emotion-5"
181
- data-wp-c16t={true}
174
+ class="components-flex-item components-color-palette__custom-color-value emotion-15 emotion-5"
175
+ data-wp-c16t="true"
182
176
  data-wp-component="FlexItem"
183
177
  >
184
178
  f00
@@ -186,40 +180,28 @@ exports[`ColorPaletteControl matches the snapshot 1`] = `
186
180
  </button>
187
181
  </div>
188
182
  <div
189
- className="components-circular-option-picker"
183
+ class="components-circular-option-picker"
190
184
  >
191
185
  <div
192
- className="components-circular-option-picker__swatches"
186
+ class="components-circular-option-picker__swatches"
193
187
  >
194
188
  <div
195
- className="components-circular-option-picker__option-wrapper"
189
+ class="components-circular-option-picker__option-wrapper"
196
190
  >
197
191
  <button
198
- aria-describedby={null}
199
192
  aria-label="Color: red"
200
- aria-pressed={true}
201
- className="components-button components-circular-option-picker__option is-pressed"
202
- onBlur={[Function]}
203
- onClick={[Function]}
204
- onFocus={[Function]}
205
- onMouseDown={[Function]}
206
- onMouseEnter={[Function]}
207
- onMouseLeave={[Function]}
208
- style={
209
- Object {
210
- "backgroundColor": "#f00",
211
- "color": "#f00",
212
- }
213
- }
193
+ aria-pressed="true"
194
+ class="components-button components-circular-option-picker__option is-pressed"
195
+ style="background-color: rgb(255, 0, 0); color: rgb(255, 0, 0);"
214
196
  type="button"
215
197
  />
216
198
  <svg
217
- aria-hidden={true}
199
+ aria-hidden="true"
218
200
  fill="#000"
219
- focusable={false}
220
- height={24}
201
+ focusable="false"
202
+ height="24"
221
203
  viewBox="0 0 24 24"
222
- width={24}
204
+ width="24"
223
205
  xmlns="http://www.w3.org/2000/svg"
224
206
  >
225
207
  <path
@@ -229,12 +211,10 @@ exports[`ColorPaletteControl matches the snapshot 1`] = `
229
211
  </div>
230
212
  </div>
231
213
  <div
232
- className="components-circular-option-picker__custom-clear-wrapper"
214
+ class="components-circular-option-picker__custom-clear-wrapper"
233
215
  >
234
216
  <button
235
- aria-describedby={null}
236
- className="components-button components-circular-option-picker__clear is-tertiary"
237
- onClick={[Function]}
217
+ class="components-button components-circular-option-picker__clear is-tertiary"
238
218
  type="button"
239
219
  >
240
220
  Clear
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * External dependencies
3
3
  */
4
- import { create, act } from 'react-test-renderer';
4
+ import { render } from '@testing-library/react';
5
5
 
6
6
  /**
7
7
  * Internal dependencies
@@ -12,20 +12,16 @@ const noop = () => {};
12
12
 
13
13
  describe( 'ColorPaletteControl', () => {
14
14
  it( 'matches the snapshot', async () => {
15
- let root;
15
+ const { container } = render(
16
+ <ColorPaletteControl
17
+ label="Test Color"
18
+ value="#f00"
19
+ colors={ [ { color: '#f00', name: 'red' } ] }
20
+ disableCustomColors={ false }
21
+ onChange={ noop }
22
+ />
23
+ );
16
24
 
17
- await act( async () => {
18
- root = create(
19
- <ColorPaletteControl
20
- label="Test Color"
21
- value="#f00"
22
- colors={ [ { color: '#f00', name: 'red' } ] }
23
- disableCustomColors={ false }
24
- onChange={ noop }
25
- />
26
- );
27
- } );
28
-
29
- expect( root.toJSON() ).toMatchSnapshot();
25
+ expect( container.firstChild ).toMatchSnapshot();
30
26
  } );
31
27
  } );
@@ -2,7 +2,7 @@
2
2
  * External dependencies
3
3
  */
4
4
  import classnames from 'classnames';
5
- import { every, isEmpty } from 'lodash';
5
+ import { isEmpty } from 'lodash';
6
6
 
7
7
  /**
8
8
  * WordPress dependencies
@@ -180,7 +180,7 @@ function ColorGradientControlSelect( props ) {
180
180
 
181
181
  function ColorGradientControl( props ) {
182
182
  if (
183
- every( colorsAndGradientKeys, ( key ) => props.hasOwnProperty( key ) )
183
+ colorsAndGradientKeys.every( ( key ) => props.hasOwnProperty( key ) )
184
184
  ) {
185
185
  return <ColorGradientControlInner { ...props } />;
186
186
  }
@@ -2,7 +2,7 @@
2
2
  * External dependencies
3
3
  */
4
4
  import classnames from 'classnames';
5
- import { every, isEmpty } from 'lodash';
5
+ import { isEmpty } from 'lodash';
6
6
 
7
7
  /**
8
8
  * WordPress dependencies
@@ -50,8 +50,7 @@ export const PanelColorGradientSettingsInner = ( {
50
50
  isEmpty( gradients ) &&
51
51
  disableCustomColors &&
52
52
  disableCustomGradients &&
53
- every(
54
- settings,
53
+ settings?.every(
55
54
  ( setting ) =>
56
55
  isEmpty( setting.colors ) &&
57
56
  isEmpty( setting.gradients ) &&
@@ -137,7 +136,7 @@ const PanelColorGradientSettingsMultipleSelect = ( props ) => {
137
136
 
138
137
  const PanelColorGradientSettings = ( props ) => {
139
138
  if (
140
- every( colorsAndGradientKeys, ( key ) => props.hasOwnProperty( key ) )
139
+ colorsAndGradientKeys.every( ( key ) => props.hasOwnProperty( key ) )
141
140
  ) {
142
141
  return <PanelColorGradientSettingsInner { ...props } />;
143
142
  }
@@ -2,7 +2,6 @@
2
2
  * External dependencies
3
3
  */
4
4
  import { render, screen } from '@testing-library/react';
5
- import { create, act } from 'react-test-renderer';
6
5
 
7
6
  /**
8
7
  * Internal dependencies
@@ -11,15 +10,6 @@ import ColorGradientControl from '../control';
11
10
 
12
11
  const noop = () => {};
13
12
 
14
- const getButtonWithAriaLabelStartPredicate =
15
- ( ariaLabelStart ) => ( element ) => {
16
- return (
17
- element.type === 'button' &&
18
- element.props[ 'aria-label' ] &&
19
- element.props[ 'aria-label' ].startsWith( ariaLabelStart )
20
- );
21
- };
22
-
23
13
  describe( 'ColorPaletteControl', () => {
24
14
  it( 'renders tabs if it is possible to select a color and a gradient rendering a color picker at the start', async () => {
25
15
  render(
@@ -64,25 +54,21 @@ describe( 'ColorPaletteControl', () => {
64
54
  } );
65
55
 
66
56
  it( 'renders the color picker and does not render tabs if it is only possible to select a color', async () => {
67
- let wrapper;
68
-
69
- await act( async () => {
70
- wrapper = create(
71
- <ColorGradientControl
72
- label="Test Color Gradient"
73
- colorValue="#f00"
74
- colors={ [
75
- { color: '#f00', name: 'red' },
76
- { color: '#0f0', name: 'green' },
77
- ] }
78
- gradients={ [] }
79
- disableCustomColors={ false }
80
- disableCustomGradients={ true }
81
- onColorChange={ noop }
82
- onGradientChange={ noop }
83
- />
84
- );
85
- } );
57
+ render(
58
+ <ColorGradientControl
59
+ label="Test Color Gradient"
60
+ colorValue="#f00"
61
+ colors={ [
62
+ { color: '#f00', name: 'red' },
63
+ { color: '#0f0', name: 'green' },
64
+ ] }
65
+ gradients={ [] }
66
+ disableCustomColors={ false }
67
+ disableCustomGradients={ true }
68
+ onColorChange={ noop }
69
+ onGradientChange={ noop }
70
+ />
71
+ );
86
72
 
87
73
  // Is not showing the two tab buttons.
88
74
  expect(
@@ -93,43 +79,35 @@ describe( 'ColorPaletteControl', () => {
93
79
  ).not.toBeInTheDocument();
94
80
 
95
81
  // Is showing the two predefined Colors.
96
- expect(
97
- wrapper.root.findAll(
98
- getButtonWithAriaLabelStartPredicate( 'Color:' )
99
- )
100
- ).toHaveLength( 2 );
82
+ expect( screen.getAllByLabelText( /^Color:/ ) ).toHaveLength( 2 );
101
83
  } );
102
84
 
103
85
  it( 'renders the gradient picker and does not render tabs if it is only possible to select a gradient', async () => {
104
- let wrapper;
105
-
106
- await act( async () => {
107
- wrapper = create(
108
- <ColorGradientControl
109
- label="Test Color Gradient"
110
- colorValue="#f00"
111
- colors={ [] }
112
- gradients={ [
113
- {
114
- gradient:
115
- 'linear-gradient(135deg,rgba(6,147,227,1) 0%,rgb(155,81,224) 100%',
116
- name: 'Vivid cyan blue to vivid purple',
117
- slug: 'vivid-cyan-blue-to-vivid-purple',
118
- },
119
- {
120
- gradient:
121
- 'linear-gradient(135deg,rgb(122,220,180) 0%,rgb(0,208,130) 100%)',
122
- name: 'Light green cyan to vivid green cyan',
123
- slug: 'light-green-cyan-to-vivid-green-cyan',
124
- },
125
- ] }
126
- disableCustomColors={ true }
127
- disableCustomGradients={ false }
128
- onColorChange={ noop }
129
- onGradientChange={ noop }
130
- />
131
- );
132
- } );
86
+ render(
87
+ <ColorGradientControl
88
+ label="Test Color Gradient"
89
+ colorValue="#f00"
90
+ colors={ [] }
91
+ gradients={ [
92
+ {
93
+ gradient:
94
+ 'linear-gradient(135deg,rgba(6,147,227,1) 0%,rgb(155,81,224) 100%',
95
+ name: 'Vivid cyan blue to vivid purple',
96
+ slug: 'vivid-cyan-blue-to-vivid-purple',
97
+ },
98
+ {
99
+ gradient:
100
+ 'linear-gradient(135deg,rgb(122,220,180) 0%,rgb(0,208,130) 100%)',
101
+ name: 'Light green cyan to vivid green cyan',
102
+ slug: 'light-green-cyan-to-vivid-green-cyan',
103
+ },
104
+ ] }
105
+ disableCustomColors={ true }
106
+ disableCustomGradients={ false }
107
+ onColorChange={ noop }
108
+ onGradientChange={ noop }
109
+ />
110
+ );
133
111
 
134
112
  // Is not showing the two tab buttons.
135
113
  expect(
@@ -140,22 +118,16 @@ describe( 'ColorPaletteControl', () => {
140
118
  ).not.toBeInTheDocument();
141
119
 
142
120
  // Is showing the two predefined Gradients.
143
- expect(
144
- wrapper.root.findAll(
145
- getButtonWithAriaLabelStartPredicate( 'Gradient:' )
146
- )
147
- ).toHaveLength( 2 );
121
+ expect( screen.getAllByLabelText( /^Gradient:/ ) ).toHaveLength( 2 );
148
122
 
149
123
  // Is showing the custom gradient picker.
150
124
  expect(
151
- wrapper.root.findAll(
152
- ( element ) =>
153
- element.props &&
154
- element.props.className &&
155
- element.props.className.includes(
156
- 'components-custom-gradient-picker'
157
- )
158
- ).length
159
- ).toBeGreaterThanOrEqual( 1 );
125
+ screen.getAllByRole( 'button', {
126
+ expanded: false,
127
+ name: /^Gradient control point at position/,
128
+ } )[ 0 ]
129
+ ).toHaveClass(
130
+ 'components-custom-gradient-picker__control-point-button'
131
+ );
160
132
  } );
161
133
  } );