@wordpress/block-editor 8.5.4 → 9.0.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 (299) hide show
  1. package/CHANGELOG.md +9 -0
  2. package/README.md +4 -2
  3. package/build/components/block-alignment-control/constants.js +48 -0
  4. package/build/components/block-alignment-control/constants.js.map +1 -0
  5. package/build/components/block-alignment-control/ui.js +9 -40
  6. package/build/components/block-alignment-control/ui.js.map +1 -1
  7. package/build/components/block-alignment-control/ui.native.js +92 -0
  8. package/build/components/block-alignment-control/ui.native.js.map +1 -0
  9. package/build/components/block-content-overlay/index.js +13 -4
  10. package/build/components/block-content-overlay/index.js.map +1 -1
  11. package/build/components/block-list/block.native.js +3 -1
  12. package/build/components/block-list/block.native.js.map +1 -1
  13. package/build/components/block-list/use-block-props/use-block-class-names.js +1 -7
  14. package/build/components/block-list/use-block-props/use-block-class-names.js.map +1 -1
  15. package/build/components/block-lock/modal.js +34 -4
  16. package/build/components/block-lock/modal.js.map +1 -1
  17. package/build/components/block-lock/toolbar.js +2 -1
  18. package/build/components/block-lock/toolbar.js.map +1 -1
  19. package/build/components/block-lock/use-block-lock.js +4 -1
  20. package/build/components/block-lock/use-block-lock.js.map +1 -1
  21. package/build/components/block-mover/button.js +4 -4
  22. package/build/components/block-mover/button.js.map +1 -1
  23. package/build/components/block-mover/index.js +39 -65
  24. package/build/components/block-mover/index.js.map +1 -1
  25. package/build/components/block-navigation/dropdown.js +11 -5
  26. package/build/components/block-navigation/dropdown.js.map +1 -1
  27. package/build/components/block-popover/inbetween.js +183 -0
  28. package/build/components/block-popover/inbetween.js.map +1 -0
  29. package/build/components/block-popover/index.js +97 -0
  30. package/build/components/block-popover/index.js.map +1 -0
  31. package/build/components/{block-tools → block-popover}/use-popover-scroll.js +4 -1
  32. package/build/components/block-popover/use-popover-scroll.js.map +1 -0
  33. package/build/components/block-styles/index.js +1 -10
  34. package/build/components/block-styles/index.js.map +1 -1
  35. package/build/components/block-tools/back-compat.js +2 -2
  36. package/build/components/block-tools/back-compat.js.map +1 -1
  37. package/build/components/block-tools/block-selection-button.js +4 -2
  38. package/build/components/block-tools/block-selection-button.js.map +1 -1
  39. package/build/components/block-tools/index.js +5 -5
  40. package/build/components/block-tools/index.js.map +1 -1
  41. package/build/components/block-tools/insertion-point.js +14 -121
  42. package/build/components/block-tools/insertion-point.js.map +1 -1
  43. package/build/components/block-tools/{block-popover.js → selected-block-popover.js} +25 -108
  44. package/build/components/block-tools/selected-block-popover.js.map +1 -0
  45. package/build/components/color-style-selector/index.js +9 -0
  46. package/build/components/color-style-selector/index.js.map +1 -1
  47. package/build/components/duotone-control/index.js +5 -1
  48. package/build/components/duotone-control/index.js.map +1 -1
  49. package/build/components/index.js +0 -9
  50. package/build/components/index.js.map +1 -1
  51. package/build/components/inserter/index.native.js +30 -8
  52. package/build/components/inserter/index.native.js.map +1 -1
  53. package/build/components/list-view/block.js +15 -15
  54. package/build/components/list-view/block.js.map +1 -1
  55. package/build/components/list-view/branch.js +9 -13
  56. package/build/components/list-view/branch.js.map +1 -1
  57. package/build/components/list-view/context.js +1 -4
  58. package/build/components/list-view/context.js.map +1 -1
  59. package/build/components/list-view/index.js +15 -32
  60. package/build/components/list-view/index.js.map +1 -1
  61. package/build/components/rich-text/index.js +0 -5
  62. package/build/components/rich-text/index.js.map +1 -1
  63. package/build/components/rich-text/index.native.js +0 -4
  64. package/build/components/rich-text/index.native.js.map +1 -1
  65. package/build/components/url-input/index.js +7 -3
  66. package/build/components/url-input/index.js.map +1 -1
  67. package/build/components/use-block-display-information/index.js +3 -1
  68. package/build/components/use-block-display-information/index.js.map +1 -1
  69. package/build/components/use-setting/index.js +42 -18
  70. package/build/components/use-setting/index.js.map +1 -1
  71. package/build/hooks/border.js +468 -44
  72. package/build/hooks/border.js.map +1 -1
  73. package/build/hooks/dimensions.js +2 -2
  74. package/build/hooks/dimensions.js.map +1 -1
  75. package/build/hooks/index.js +3 -1
  76. package/build/hooks/index.js.map +1 -1
  77. package/build/hooks/margin.js +64 -12
  78. package/build/hooks/margin.js.map +1 -1
  79. package/build/hooks/padding.js +60 -12
  80. package/build/hooks/padding.js.map +1 -1
  81. package/build/hooks/settings.js +32 -0
  82. package/build/hooks/settings.js.map +1 -0
  83. package/build/hooks/use-border-props.js +22 -32
  84. package/build/hooks/use-border-props.js.map +1 -1
  85. package/build/store/actions.js +14 -2
  86. package/build/store/actions.js.map +1 -1
  87. package/build/store/defaults.js +0 -1
  88. package/build/store/defaults.js.map +1 -1
  89. package/build/store/reducer.js +0 -26
  90. package/build/store/reducer.js.map +1 -1
  91. package/build/store/selectors.js +47 -15
  92. package/build/store/selectors.js.map +1 -1
  93. package/build-module/components/block-alignment-control/constants.js +36 -0
  94. package/build-module/components/block-alignment-control/constants.js.map +1 -0
  95. package/build-module/components/block-alignment-control/ui.js +4 -35
  96. package/build-module/components/block-alignment-control/ui.js.map +1 -1
  97. package/build-module/components/block-alignment-control/ui.native.js +78 -0
  98. package/build-module/components/block-alignment-control/ui.native.js.map +1 -0
  99. package/build-module/components/block-content-overlay/index.js +13 -4
  100. package/build-module/components/block-content-overlay/index.js.map +1 -1
  101. package/build-module/components/block-list/block.native.js +3 -1
  102. package/build-module/components/block-list/block.native.js.map +1 -1
  103. package/build-module/components/block-list/use-block-props/use-block-class-names.js +1 -7
  104. package/build-module/components/block-list/use-block-props/use-block-class-names.js.map +1 -1
  105. package/build-module/components/block-lock/modal.js +34 -5
  106. package/build-module/components/block-lock/modal.js.map +1 -1
  107. package/build-module/components/block-lock/toolbar.js +2 -1
  108. package/build-module/components/block-lock/toolbar.js.map +1 -1
  109. package/build-module/components/block-lock/use-block-lock.js +4 -1
  110. package/build-module/components/block-lock/use-block-lock.js.map +1 -1
  111. package/build-module/components/block-mover/button.js +5 -5
  112. package/build-module/components/block-mover/button.js.map +1 -1
  113. package/build-module/components/block-mover/index.js +38 -63
  114. package/build-module/components/block-mover/index.js.map +1 -1
  115. package/build-module/components/block-navigation/dropdown.js +10 -5
  116. package/build-module/components/block-navigation/dropdown.js.map +1 -1
  117. package/build-module/components/block-popover/inbetween.js +165 -0
  118. package/build-module/components/block-popover/inbetween.js.map +1 -0
  119. package/build-module/components/block-popover/index.js +83 -0
  120. package/build-module/components/block-popover/index.js.map +1 -0
  121. package/build-module/components/{block-tools → block-popover}/use-popover-scroll.js +3 -1
  122. package/build-module/components/block-popover/use-popover-scroll.js.map +1 -0
  123. package/build-module/components/block-styles/index.js +1 -9
  124. package/build-module/components/block-styles/index.js.map +1 -1
  125. package/build-module/components/block-tools/back-compat.js +1 -1
  126. package/build-module/components/block-tools/back-compat.js.map +1 -1
  127. package/build-module/components/block-tools/block-selection-button.js +3 -2
  128. package/build-module/components/block-tools/block-selection-button.js.map +1 -1
  129. package/build-module/components/block-tools/index.js +3 -3
  130. package/build-module/components/block-tools/index.js.map +1 -1
  131. package/build-module/components/block-tools/insertion-point.js +16 -121
  132. package/build-module/components/block-tools/insertion-point.js.map +1 -1
  133. package/build-module/components/block-tools/{block-popover.js → selected-block-popover.js} +25 -105
  134. package/build-module/components/block-tools/selected-block-popover.js.map +1 -0
  135. package/build-module/components/color-style-selector/index.js +6 -0
  136. package/build-module/components/color-style-selector/index.js.map +1 -1
  137. package/build-module/components/duotone-control/index.js +4 -1
  138. package/build-module/components/duotone-control/index.js.map +1 -1
  139. package/build-module/components/index.js +0 -1
  140. package/build-module/components/index.js.map +1 -1
  141. package/build-module/components/inserter/index.native.js +31 -10
  142. package/build-module/components/inserter/index.native.js.map +1 -1
  143. package/build-module/components/list-view/block.js +15 -16
  144. package/build-module/components/list-view/block.js.map +1 -1
  145. package/build-module/components/list-view/branch.js +9 -13
  146. package/build-module/components/list-view/branch.js.map +1 -1
  147. package/build-module/components/list-view/context.js +1 -4
  148. package/build-module/components/list-view/context.js.map +1 -1
  149. package/build-module/components/list-view/index.js +15 -31
  150. package/build-module/components/list-view/index.js.map +1 -1
  151. package/build-module/components/rich-text/index.js +0 -4
  152. package/build-module/components/rich-text/index.js.map +1 -1
  153. package/build-module/components/rich-text/index.native.js +0 -4
  154. package/build-module/components/rich-text/index.native.js.map +1 -1
  155. package/build-module/components/url-input/index.js +7 -3
  156. package/build-module/components/url-input/index.js.map +1 -1
  157. package/build-module/components/use-block-display-information/index.js +3 -1
  158. package/build-module/components/use-block-display-information/index.js.map +1 -1
  159. package/build-module/components/use-setting/index.js +43 -19
  160. package/build-module/components/use-setting/index.js.map +1 -1
  161. package/build-module/hooks/border.js +458 -44
  162. package/build-module/hooks/border.js.map +1 -1
  163. package/build-module/hooks/dimensions.js +5 -5
  164. package/build-module/hooks/dimensions.js.map +1 -1
  165. package/build-module/hooks/index.js +2 -1
  166. package/build-module/hooks/index.js.map +1 -1
  167. package/build-module/hooks/margin.js +61 -13
  168. package/build-module/hooks/margin.js.map +1 -1
  169. package/build-module/hooks/padding.js +57 -13
  170. package/build-module/hooks/padding.js.map +1 -1
  171. package/build-module/hooks/settings.js +29 -0
  172. package/build-module/hooks/settings.js.map +1 -0
  173. package/build-module/hooks/use-border-props.js +21 -30
  174. package/build-module/hooks/use-border-props.js.map +1 -1
  175. package/build-module/store/actions.js +14 -2
  176. package/build-module/store/actions.js.map +1 -1
  177. package/build-module/store/defaults.js +0 -1
  178. package/build-module/store/defaults.js.map +1 -1
  179. package/build-module/store/reducer.js +0 -24
  180. package/build-module/store/reducer.js.map +1 -1
  181. package/build-module/store/selectors.js +44 -15
  182. package/build-module/store/selectors.js.map +1 -1
  183. package/build-style/style-rtl.css +128 -276
  184. package/build-style/style.css +128 -276
  185. package/package.json +28 -28
  186. package/src/components/block-alignment-control/constants.js +45 -0
  187. package/src/components/block-alignment-control/ui.js +69 -109
  188. package/src/components/block-alignment-control/ui.native.js +86 -0
  189. package/src/components/block-content-overlay/index.js +19 -2
  190. package/src/components/block-list/block.native.js +2 -0
  191. package/src/components/block-list/style.scss +7 -18
  192. package/src/components/block-list/use-block-props/use-block-class-names.js +1 -11
  193. package/src/components/block-lock/modal.js +42 -3
  194. package/src/components/block-lock/toolbar.js +2 -2
  195. package/src/components/block-lock/use-block-lock.js +4 -1
  196. package/src/components/block-mover/button.js +5 -7
  197. package/src/components/block-mover/index.js +37 -60
  198. package/src/components/block-mover/stories/index.js +110 -0
  199. package/src/components/block-mover/style.scss +48 -138
  200. package/src/components/block-navigation/dropdown.js +12 -8
  201. package/src/components/block-popover/README.md +41 -0
  202. package/src/components/block-popover/inbetween.js +180 -0
  203. package/src/components/block-popover/index.js +90 -0
  204. package/src/components/block-popover/style.scss +27 -0
  205. package/src/components/{block-tools → block-popover}/use-popover-scroll.js +3 -1
  206. package/src/components/block-styles/index.js +1 -12
  207. package/src/components/block-switcher/style.scss +0 -4
  208. package/src/components/block-toolbar/style.scss +0 -12
  209. package/src/components/block-tools/back-compat.js +1 -1
  210. package/src/components/block-tools/block-selection-button.js +3 -1
  211. package/src/components/block-tools/index.js +6 -4
  212. package/src/components/block-tools/insertion-point.js +19 -152
  213. package/src/components/block-tools/{block-popover.js → selected-block-popover.js} +24 -116
  214. package/src/components/block-tools/style.scss +11 -123
  215. package/src/components/border-radius-control/style.scss +5 -2
  216. package/src/components/color-palette/test/__snapshots__/control.js.snap +1 -1
  217. package/src/components/color-style-selector/index.js +18 -9
  218. package/src/components/default-block-appender/style.scss +1 -2
  219. package/src/components/duotone-control/index.js +8 -1
  220. package/src/components/gradients/README.md +29 -0
  221. package/src/components/image-size-control/README.md +1 -1
  222. package/src/components/index.js +0 -1
  223. package/src/components/inserter/index.native.js +60 -25
  224. package/src/components/inserter/style.native.scss +25 -3
  225. package/src/components/list-view/block.js +24 -34
  226. package/src/components/list-view/branch.js +10 -20
  227. package/src/components/list-view/context.js +1 -4
  228. package/src/components/list-view/index.js +11 -41
  229. package/src/components/navigable-toolbar/README.md +16 -0
  230. package/src/components/rich-text/index.js +0 -2
  231. package/src/components/rich-text/index.native.js +0 -4
  232. package/src/components/url-input/index.js +6 -3
  233. package/src/components/use-block-display-information/index.js +2 -0
  234. package/src/components/use-setting/index.js +57 -21
  235. package/src/hooks/border.js +438 -72
  236. package/src/hooks/border.scss +48 -0
  237. package/src/hooks/dimensions.js +44 -38
  238. package/src/hooks/index.js +2 -1
  239. package/src/hooks/margin.js +64 -15
  240. package/src/hooks/padding.js +60 -15
  241. package/src/hooks/padding.scss +12 -0
  242. package/src/hooks/settings.js +32 -0
  243. package/src/hooks/test/settings.js +48 -0
  244. package/src/hooks/use-border-props.js +15 -32
  245. package/src/store/actions.js +14 -2
  246. package/src/store/defaults.js +0 -1
  247. package/src/store/reducer.js +0 -21
  248. package/src/store/selectors.js +46 -15
  249. package/src/store/test/actions.js +0 -18
  250. package/src/store/test/reducer.js +0 -19
  251. package/src/store/test/selectors.js +17 -19
  252. package/src/style.scss +2 -2
  253. package/tsconfig.tsbuildinfo +1 -1
  254. package/build/components/block-mobile-toolbar/index.js +0 -42
  255. package/build/components/block-mobile-toolbar/index.js.map +0 -1
  256. package/build/components/block-tools/block-popover.js.map +0 -1
  257. package/build/components/block-tools/use-popover-scroll.js.map +0 -1
  258. package/build/components/border-style-control/index.js +0 -60
  259. package/build/components/border-style-control/index.js.map +0 -1
  260. package/build/components/list-view/appender.js +0 -93
  261. package/build/components/list-view/appender.js.map +0 -1
  262. package/build/components/list-view/list-item.js +0 -62
  263. package/build/components/list-view/list-item.js.map +0 -1
  264. package/build/components/rich-text/use-caret-in-format.js +0 -43
  265. package/build/components/rich-text/use-caret-in-format.js.map +0 -1
  266. package/build/hooks/border-color.js +0 -302
  267. package/build/hooks/border-color.js.map +0 -1
  268. package/build/hooks/border-style.js +0 -96
  269. package/build/hooks/border-style.js.map +0 -1
  270. package/build/hooks/border-width.js +0 -162
  271. package/build/hooks/border-width.js.map +0 -1
  272. package/build-module/components/block-mobile-toolbar/index.js +0 -31
  273. package/build-module/components/block-mobile-toolbar/index.js.map +0 -1
  274. package/build-module/components/block-tools/block-popover.js.map +0 -1
  275. package/build-module/components/block-tools/use-popover-scroll.js.map +0 -1
  276. package/build-module/components/border-style-control/index.js +0 -50
  277. package/build-module/components/border-style-control/index.js.map +0 -1
  278. package/build-module/components/list-view/appender.js +0 -76
  279. package/build-module/components/list-view/appender.js.map +0 -1
  280. package/build-module/components/list-view/list-item.js +0 -47
  281. package/build-module/components/list-view/list-item.js.map +0 -1
  282. package/build-module/components/rich-text/use-caret-in-format.js +0 -33
  283. package/build-module/components/rich-text/use-caret-in-format.js.map +0 -1
  284. package/build-module/hooks/border-color.js +0 -276
  285. package/build-module/hooks/border-color.js.map +0 -1
  286. package/build-module/hooks/border-style.js +0 -78
  287. package/build-module/hooks/border-style.js.map +0 -1
  288. package/build-module/hooks/border-width.js +0 -143
  289. package/build-module/hooks/border-width.js.map +0 -1
  290. package/src/components/block-mobile-toolbar/index.js +0 -24
  291. package/src/components/block-mobile-toolbar/style.scss +0 -29
  292. package/src/components/border-style-control/index.js +0 -47
  293. package/src/components/border-style-control/style.scss +0 -18
  294. package/src/components/list-view/appender.js +0 -82
  295. package/src/components/list-view/list-item.js +0 -59
  296. package/src/components/rich-text/use-caret-in-format.js +0 -28
  297. package/src/hooks/border-color.js +0 -315
  298. package/src/hooks/border-style.js +0 -64
  299. package/src/hooks/border-width.js +0 -139
@@ -10,9 +10,7 @@ import classnames from 'classnames';
10
10
 
11
11
  import { dragHandle } from '@wordpress/icons';
12
12
  import { ToolbarGroup, ToolbarItem, Button } from '@wordpress/components';
13
- import { getBlockType } from '@wordpress/blocks';
14
- import { useState } from '@wordpress/element';
15
- import { withSelect } from '@wordpress/data';
13
+ import { useSelect } from '@wordpress/data';
16
14
  import { __ } from '@wordpress/i18n';
17
15
 
18
16
  /**
@@ -22,20 +20,35 @@ import BlockDraggable from '../block-draggable';
22
20
  import { BlockMoverUpButton, BlockMoverDownButton } from './button';
23
21
  import { store as blockEditorStore } from '../../store';
24
22
 
25
- function BlockMover( {
26
- isFirst,
27
- isLast,
28
- clientIds,
29
- canMove,
30
- isHidden,
31
- rootClientId,
32
- orientation,
33
- hideDragHandle,
34
- } ) {
35
- const [ isFocused, setIsFocused ] = useState( false );
23
+ function BlockMover( { clientIds, hideDragHandle } ) {
24
+ const { canMove, rootClientId, isFirst, isLast, orientation } = useSelect(
25
+ ( select ) => {
26
+ const {
27
+ getBlockIndex,
28
+ getBlockListSettings,
29
+ canMoveBlocks,
30
+ getBlockOrder,
31
+ getBlockRootClientId,
32
+ } = select( blockEditorStore );
33
+ const normalizedClientIds = castArray( clientIds );
34
+ const firstClientId = first( normalizedClientIds );
35
+ const _rootClientId = getBlockRootClientId(
36
+ first( normalizedClientIds )
37
+ );
38
+ const firstIndex = getBlockIndex( firstClientId );
39
+ const lastIndex = getBlockIndex( last( normalizedClientIds ) );
40
+ const blockOrder = getBlockOrder( _rootClientId );
36
41
 
37
- const onFocus = () => setIsFocused( true );
38
- const onBlur = () => setIsFocused( false );
42
+ return {
43
+ canMove: canMoveBlocks( clientIds, _rootClientId ),
44
+ rootClientId: _rootClientId,
45
+ isFirst: firstIndex === 0,
46
+ isLast: lastIndex === blockOrder.length - 1,
47
+ orientation: getBlockListSettings( _rootClientId )?.orientation,
48
+ };
49
+ },
50
+ [ clientIds ]
51
+ );
39
52
 
40
53
  if ( ! canMove || ( isFirst && isLast && ! rootClientId ) ) {
41
54
  return null;
@@ -43,22 +56,14 @@ function BlockMover( {
43
56
 
44
57
  const dragHandleLabel = __( 'Drag' );
45
58
 
46
- // We emulate a disabled state because forcefully applying the `disabled`
47
- // attribute on the buttons while it has focus causes the screen to change
48
- // to an unfocused state (body as active element) without firing blur on,
49
- // the rendering parent, leaving it unable to react to focus out.
50
59
  return (
51
- <div
60
+ <ToolbarGroup
52
61
  className={ classnames( 'block-editor-block-mover', {
53
- 'is-visible': isFocused || ! isHidden,
54
62
  'is-horizontal': orientation === 'horizontal',
55
63
  } ) }
56
64
  >
57
65
  { ! hideDragHandle && (
58
- <BlockDraggable
59
- clientIds={ clientIds }
60
- cloneClassname="block-editor-block-mover__drag-clone"
61
- >
66
+ <BlockDraggable clientIds={ clientIds }>
62
67
  { ( draggableProps ) => (
63
68
  <Button
64
69
  icon={ dragHandle }
@@ -73,8 +78,8 @@ function BlockMover( {
73
78
  ) }
74
79
  </BlockDraggable>
75
80
  ) }
76
- <ToolbarGroup className="block-editor-block-mover__move-button-container">
77
- <ToolbarItem onFocus={ onFocus } onBlur={ onBlur }>
81
+ <div className="block-editor-block-mover__move-button-container">
82
+ <ToolbarItem>
78
83
  { ( itemProps ) => (
79
84
  <BlockMoverUpButton
80
85
  clientIds={ clientIds }
@@ -82,7 +87,7 @@ function BlockMover( {
82
87
  />
83
88
  ) }
84
89
  </ToolbarItem>
85
- <ToolbarItem onFocus={ onFocus } onBlur={ onBlur }>
90
+ <ToolbarItem>
86
91
  { ( itemProps ) => (
87
92
  <BlockMoverDownButton
88
93
  clientIds={ clientIds }
@@ -90,40 +95,12 @@ function BlockMover( {
90
95
  />
91
96
  ) }
92
97
  </ToolbarItem>
93
- </ToolbarGroup>
94
- </div>
98
+ </div>
99
+ </ToolbarGroup>
95
100
  );
96
101
  }
97
102
 
98
103
  /**
99
104
  * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/block-mover/README.md
100
105
  */
101
- export default withSelect( ( select, { clientIds } ) => {
102
- const {
103
- getBlock,
104
- getBlockIndex,
105
- getBlockListSettings,
106
- canMoveBlocks,
107
- getBlockOrder,
108
- getBlockRootClientId,
109
- } = select( blockEditorStore );
110
- const normalizedClientIds = castArray( clientIds );
111
- const firstClientId = first( normalizedClientIds );
112
- const block = getBlock( firstClientId );
113
- const rootClientId = getBlockRootClientId( first( normalizedClientIds ) );
114
- const firstIndex = getBlockIndex( firstClientId );
115
- const lastIndex = getBlockIndex( last( normalizedClientIds ) );
116
- const blockOrder = getBlockOrder( rootClientId );
117
- const isFirst = firstIndex === 0;
118
- const isLast = lastIndex === blockOrder.length - 1;
119
-
120
- return {
121
- blockType: block ? getBlockType( block.name ) : null,
122
- canMove: canMoveBlocks( clientIds, rootClientId ),
123
- rootClientId,
124
- firstIndex,
125
- isFirst,
126
- isLast,
127
- orientation: getBlockListSettings( rootClientId )?.orientation,
128
- };
129
- } )( BlockMover );
106
+ export default BlockMover;
@@ -0,0 +1,110 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import { useEffect } from '@wordpress/element';
5
+ import { createBlock } from '@wordpress/blocks';
6
+ import { registerCoreBlocks } from '@wordpress/block-library';
7
+ import { useDispatch } from '@wordpress/data';
8
+ import { Toolbar } from '@wordpress/components';
9
+
10
+ /**
11
+ * Internal dependencies
12
+ */
13
+ import BlockMover from '../';
14
+ import BlockEditorProvider from '../../provider';
15
+ import { store as blockEditorStore } from '../../../store';
16
+
17
+ registerCoreBlocks();
18
+ const blocks = [
19
+ // vertical
20
+ createBlock( 'core/group', { layout: { type: 'flex' } }, [
21
+ createBlock( 'core/paragraph' ),
22
+ createBlock( 'core/paragraph' ),
23
+ createBlock( 'core/paragraph' ),
24
+ ] ),
25
+ // horizontal
26
+ createBlock( 'core/buttons', {}, [
27
+ createBlock( 'core/button' ),
28
+ createBlock( 'core/button' ),
29
+ createBlock( 'core/button' ),
30
+ ] ),
31
+ ];
32
+
33
+ function Provider( { children } ) {
34
+ const wrapperStyle = { margin: '24px', position: 'relative' };
35
+
36
+ return (
37
+ <div style={ wrapperStyle }>
38
+ <BlockEditorProvider value={ blocks }>
39
+ { children }
40
+ </BlockEditorProvider>
41
+ </div>
42
+ );
43
+ }
44
+
45
+ function BlockMoverStory() {
46
+ const { updateBlockListSettings } = useDispatch( blockEditorStore );
47
+
48
+ useEffect( () => {
49
+ /**
50
+ * This shouldn't be needed but unfortunatley
51
+ * the layout orientation is not declarative, we need
52
+ * to render the blocks to update the block settings in the state.
53
+ */
54
+ updateBlockListSettings( blocks[ 1 ].clientId, {
55
+ orientation: 'horizontal',
56
+ } );
57
+ }, [] );
58
+
59
+ return (
60
+ <div>
61
+ <p>The mover by default is vertical</p>
62
+ <Toolbar label="Block Mover">
63
+ <BlockMover
64
+ clientIds={
65
+ blocks.length
66
+ ? [ blocks[ 0 ].innerBlocks[ 1 ].clientId ]
67
+ : []
68
+ }
69
+ />
70
+ </Toolbar>
71
+
72
+ <p style={ { marginTop: 36 } }>
73
+ But it can also accomodate horizontal blocks.
74
+ </p>
75
+ <Toolbar label="Block Mover">
76
+ <BlockMover
77
+ clientIds={
78
+ blocks.length
79
+ ? [ blocks[ 1 ].innerBlocks[ 1 ].clientId ]
80
+ : []
81
+ }
82
+ />
83
+ </Toolbar>
84
+
85
+ <p style={ { marginTop: 36 } }>We can also hide the drag handle.</p>
86
+ <Toolbar label="Block Mover">
87
+ <BlockMover
88
+ clientIds={
89
+ blocks.length
90
+ ? [ blocks[ 1 ].innerBlocks[ 0 ].clientId ]
91
+ : []
92
+ }
93
+ hideDragHandle
94
+ />
95
+ </Toolbar>
96
+ </div>
97
+ );
98
+ }
99
+
100
+ export default {
101
+ title: 'BlockEditor/BlockMover',
102
+ };
103
+
104
+ export const _default = () => {
105
+ return (
106
+ <Provider>
107
+ <BlockMoverStory />
108
+ </Provider>
109
+ );
110
+ };
@@ -1,159 +1,69 @@
1
- .block-editor-block-mover-button__description {
2
- display: none;
3
- }
4
-
5
- .block-editor-block-mover-button.has-icon {
1
+ .block-editor-block-mover__move-button-container {
2
+ display: flex;
6
3
  padding: 0;
7
- }
8
-
9
- // Show the mover in a single button under the contextual toolbar.
10
- .block-editor-block-mover {
11
- display: inline-flex;
12
- flex-direction: row;
13
-
14
- .block-editor-block-mover__move-button-container,
15
- .components-toolbar {
16
- flex: 1;
4
+ border: none;
17
5
 
18
- // Increase touch targets on mobile.
19
- flex-direction: row;
20
- border-right: none !important;
21
-
22
- @include break-small() {
6
+ @include break-small() {
7
+ .block-editor-block-mover:not(.is-horizontal) & {
23
8
  flex-direction: column;
24
- }
25
-
26
- // @todo: override toolbar group inherited paddings from components/block-tools/style.scss.
27
- // This is best fixed by making the mover control area a proper single toolbar group.
28
- padding: 0;
29
- }
30
-
31
- &.is-horizontal .block-editor-block-mover__move-button-container,
32
- &.is-horizontal .components-toolbar {
33
- flex-direction: row;
34
- }
35
-
36
- .block-editor-block-mover-button {
37
- &.block-editor-block-mover-button {
38
- padding-right: 0;
39
- padding-left: 0;
40
- min-width: $button-size;
41
- }
42
-
43
- @include break-small() {
44
- // The !important modifier should be removed when https://github.com/WordPress/gutenberg/issues/24898 refactors the spacing grid.
45
- height: $block-toolbar-height*0.5;
46
- width: $block-toolbar-height - $grid-unit-15 * 0.5;
47
- padding-right: $grid-unit-15 - $border-width !important;
48
- padding-left: $grid-unit-15 * 0.5 !important;
49
-
50
- // Extra specificity to override standard toolbar button styles.
51
- &.block-editor-block-mover-button {
52
- min-width: $block-toolbar-height - $grid-unit-15 * 0.5;
9
+ width: $block-toolbar-height - $grid-unit-15;
10
+
11
+ > * {
12
+ height: $block-toolbar-height * 0.5;
13
+ width: 100%;
14
+ min-width: 0 !important; // overrides default button width.
15
+
16
+ // Focus style.
17
+ &::before {
18
+ height: 100%;
19
+ width: 100%;
20
+ }
53
21
  }
54
- }
55
22
 
56
- // Focus style.
57
- // Overrides .components-toolbar-group styles
58
- &::before {
59
- @include break-small() {
60
- left: $grid-unit-10 !important;
61
- right: $grid-unit-10 !important;
23
+ .block-editor-block-mover-button.is-up-button svg {
24
+ top: 5px;
25
+ flex-shrink: 0;
62
26
  }
63
- }
64
- }
65
27
 
66
- .block-editor-block-mover__drag-handle {
67
- width: $button-size-small;
68
- cursor: grab;
69
-
70
- // The !important modifier should be removed when https://github.com/WordPress/gutenberg/issues/24898 refactors the spacing grid.
71
- min-width: $button-size-small !important;
72
- padding: 0 !important;
73
-
74
- &:focus::before {
75
- left: 0 !important;
76
- right: 0 !important;
77
- }
78
- }
79
-
80
- // Position the icons correctly.
81
- @include break-small() {
82
- .components-toolbar-group .block-editor-block-mover-button,
83
- .components-toolbar .block-editor-block-mover-button {
84
- margin: 0 auto 0 0;
85
- }
86
-
87
- // Up button.
88
- .components-toolbar-group .block-editor-block-mover-button.is-up-button,
89
- .components-toolbar .block-editor-block-mover-button.is-up-button {
90
- // Focus style.
91
- &::before {
92
- bottom: 0;
93
- height: calc(100% - #{ $border-width });
28
+ .block-editor-block-mover-button.is-down-button svg {
29
+ bottom: 5px;
30
+ flex-shrink: 0;
94
31
  }
95
32
  }
96
33
 
97
- // Down button.
98
- .components-toolbar-group .block-editor-block-mover-button.is-down-button,
99
- .components-toolbar .block-editor-block-mover-button.is-down-button {
100
- // Focus style.
101
- &::before {
102
- top: 0;
103
- height: calc(100% - #{ $border-width });
104
- }
105
- }
106
- }
34
+ .block-editor-block-mover.is-horizontal & {
35
+ width: $block-toolbar-height;
107
36
 
108
- // Mover is horizontal.
109
- &.is-horizontal {
110
- .block-editor-block-mover-button.has-icon {
111
- height: $block-toolbar-height;
112
- // Overrides .components-toolbar-group styles
113
- width: $block-toolbar-height * 0.5;
114
- padding-left: 0;
115
- padding-right: 0;
37
+ > * {
38
+ width: $block-toolbar-height * 0.5;
39
+ min-width: 0 !important; // overrides default button width.
40
+ padding-left: 0 !important;
41
+ padding-right: 0 !important;
42
+ overflow: hidden;
116
43
 
117
- // Focus style.
118
- &::before {
119
- top: $border-width;
120
- bottom: $border-width;
121
- min-width: 0;
122
- width: auto;
123
- height: auto;
44
+ // Focus style.
45
+ &::before {
46
+ height: 100%;
47
+ }
124
48
  }
125
- }
126
49
 
127
- // Position the icons correctly.
128
- .block-editor-block-mover-button.is-up-button.has-icon {
129
- svg {
130
- margin-left: 0;
131
- margin-right: -$grid-unit-10;
132
- margin-bottom: 0;
50
+ .block-editor-block-mover-button.is-up-button svg {
51
+ left: 5px;
133
52
  }
134
53
 
135
- // Focus style.
136
- // Overrides .components-toolbar-group styles
137
- &::before {
138
- left: 0 !important;
139
- right: 0 !important;
54
+ .block-editor-block-mover-button.is-down-button svg {
55
+ right: 5px;
140
56
  }
141
57
  }
58
+ }
59
+ }
142
60
 
143
- .block-editor-block-mover-button.is-down-button.has-icon {
144
- svg {
145
- margin-left: -$grid-unit-10;
146
- margin-right: 0;
147
- margin-top: 0;
148
- }
149
-
150
- // Focus style.
151
- // Overrides .components-toolbar-group styles
152
- &::before {
153
- left: 0 !important;
154
- right: 0 !important;
155
- width: calc(100% + #{ $border-width });
156
- }
157
- }
61
+ .block-editor-block-mover__drag-handle {
62
+ @include break-small() {
63
+ width: $block-toolbar-height * 0.5;
64
+ min-width: 0 !important; // overrides default button width.
65
+ padding-left: 0 !important;
66
+ padding-right: 0 !important;
67
+ overflow: hidden;
158
68
  }
159
69
  }
@@ -1,3 +1,8 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import deprecated from '@wordpress/deprecated';
5
+
1
6
  /**
2
7
  * WordPress dependencies
3
8
  */
@@ -36,10 +41,12 @@ function BlockNavigationDropdownToggle( {
36
41
  );
37
42
  }
38
43
 
39
- function BlockNavigationDropdown(
40
- { isDisabled, __experimentalFeatures, ...props },
41
- ref
42
- ) {
44
+ function BlockNavigationDropdown( { isDisabled, ...props }, ref ) {
45
+ deprecated( 'wp.blockEditor.BlockNavigationDropdown', {
46
+ since: '6.1',
47
+ alternative: 'wp.components.Dropdown and wp.blockEditor.ListView',
48
+ } );
49
+
43
50
  const hasBlocks = useSelect(
44
51
  ( select ) => !! select( blockEditorStore ).getBlockCount(),
45
52
  []
@@ -65,10 +72,7 @@ function BlockNavigationDropdown(
65
72
  { __( 'List view' ) }
66
73
  </p>
67
74
 
68
- <ListView
69
- showNestedBlocks
70
- __experimentalFeatures={ __experimentalFeatures }
71
- />
75
+ <ListView />
72
76
  </div>
73
77
  ) }
74
78
  />
@@ -0,0 +1,41 @@
1
+ # BlockPopover and BlockPopoverInbetween
2
+
3
+ These two components allow rendering editor UI by the block (in a popover) but outside the canvas. This is important to avoid messing with the style and layout of the block list.
4
+
5
+ For example, it's used to render the contextual block toolbar and the in-between block inserter.
6
+
7
+ ## BlockPopover
8
+
9
+ ### Props
10
+
11
+ #### clientId
12
+
13
+ The client ID of the block representing the top position of the popover.
14
+
15
+ - Type: `String`
16
+ - Required: Yes
17
+
18
+ #### bottomClientId
19
+
20
+ The client ID of the block representing the bottom position of the popover.
21
+
22
+ - Type: `String`
23
+ - Required: No
24
+
25
+ ## BlockPopoverInbetween
26
+
27
+ ### Props
28
+
29
+ #### previousClientId
30
+
31
+ The client ID of the block before the popover.
32
+
33
+ - Type: `String`
34
+ - Required: Yes
35
+
36
+ #### nextClientId
37
+
38
+ The client ID of the block after the popover.
39
+
40
+ - Type: `String`
41
+ - Required: Yes