@wordpress/block-editor 8.5.0 → 8.6.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 (274) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/build/components/block-alignment-control/ui.js +1 -1
  3. package/build/components/block-alignment-control/ui.js.map +1 -1
  4. package/build/components/block-content-overlay/index.js +13 -4
  5. package/build/components/block-content-overlay/index.js.map +1 -1
  6. package/build/components/block-list/block.native.js +3 -1
  7. package/build/components/block-list/block.native.js.map +1 -1
  8. package/build/components/block-lock/index.js +8 -0
  9. package/build/components/block-lock/index.js.map +1 -1
  10. package/build/components/block-lock/menu-item.js +5 -20
  11. package/build/components/block-lock/menu-item.js.map +1 -1
  12. package/build/components/block-lock/modal.js +33 -12
  13. package/build/components/block-lock/modal.js.map +1 -1
  14. package/build/components/block-lock/toolbar.js +7 -20
  15. package/build/components/block-lock/toolbar.js.map +1 -1
  16. package/build/components/block-lock/use-block-lock.js +50 -0
  17. package/build/components/block-lock/use-block-lock.js.map +1 -0
  18. package/build/components/block-mover/button.js +4 -4
  19. package/build/components/block-mover/button.js.map +1 -1
  20. package/build/components/block-mover/index.js +39 -65
  21. package/build/components/block-mover/index.js.map +1 -1
  22. package/build/components/block-pattern-setup/index.js +37 -22
  23. package/build/components/block-pattern-setup/index.js.map +1 -1
  24. package/build/components/block-pattern-setup/setup-toolbar.js +1 -1
  25. package/build/components/block-pattern-setup/setup-toolbar.js.map +1 -1
  26. package/build/components/block-popover/inbetween.js +183 -0
  27. package/build/components/block-popover/inbetween.js.map +1 -0
  28. package/build/components/block-popover/index.js +82 -0
  29. package/build/components/block-popover/index.js.map +1 -0
  30. package/build/components/{block-tools → block-popover}/use-popover-scroll.js +4 -1
  31. package/build/components/block-popover/use-popover-scroll.js.map +1 -0
  32. package/build/components/block-preview/auto.js +6 -3
  33. package/build/components/block-preview/auto.js.map +1 -1
  34. package/build/components/block-preview/index.js +4 -2
  35. package/build/components/block-preview/index.js.map +1 -1
  36. package/build/components/block-styles/index.js +1 -10
  37. package/build/components/block-styles/index.js.map +1 -1
  38. package/build/components/block-switcher/index.js +7 -2
  39. package/build/components/block-switcher/index.js.map +1 -1
  40. package/build/components/block-tools/back-compat.js +2 -2
  41. package/build/components/block-tools/back-compat.js.map +1 -1
  42. package/build/components/block-tools/block-selection-button.js +4 -2
  43. package/build/components/block-tools/block-selection-button.js.map +1 -1
  44. package/build/components/block-tools/index.js +5 -5
  45. package/build/components/block-tools/index.js.map +1 -1
  46. package/build/components/block-tools/insertion-point.js +14 -121
  47. package/build/components/block-tools/insertion-point.js.map +1 -1
  48. package/build/components/block-tools/{block-popover.js → selected-block-popover.js} +25 -108
  49. package/build/components/block-tools/selected-block-popover.js.map +1 -0
  50. package/build/components/copy-handler/index.js +44 -9
  51. package/build/components/copy-handler/index.js.map +1 -1
  52. package/build/components/duotone-control/index.js +5 -1
  53. package/build/components/duotone-control/index.js.map +1 -1
  54. package/build/components/inserter/index.native.js +30 -8
  55. package/build/components/inserter/index.native.js.map +1 -1
  56. package/build/components/link-control/index.js +6 -7
  57. package/build/components/link-control/index.js.map +1 -1
  58. package/build/components/list-view/block-select-button.js +4 -10
  59. package/build/components/list-view/block-select-button.js.map +1 -1
  60. package/build/components/list-view/block.js +13 -2
  61. package/build/components/list-view/block.js.map +1 -1
  62. package/build/components/rich-text/index.js +0 -5
  63. package/build/components/rich-text/index.js.map +1 -1
  64. package/build/components/rich-text/index.native.js +0 -4
  65. package/build/components/rich-text/index.native.js.map +1 -1
  66. package/build/components/use-block-display-information/index.js +3 -1
  67. package/build/components/use-block-display-information/index.js.map +1 -1
  68. package/build/hooks/border.js +468 -44
  69. package/build/hooks/border.js.map +1 -1
  70. package/build/hooks/duotone.js +66 -16
  71. package/build/hooks/duotone.js.map +1 -1
  72. package/build/hooks/index.js +8 -2
  73. package/build/hooks/index.js.map +1 -1
  74. package/build/hooks/use-border-props.js +22 -32
  75. package/build/hooks/use-border-props.js.map +1 -1
  76. package/build/index.js +7 -0
  77. package/build/index.js.map +1 -1
  78. package/build/store/actions.js +36 -31
  79. package/build/store/actions.js.map +1 -1
  80. package/build/store/reducer.js +0 -26
  81. package/build/store/reducer.js.map +1 -1
  82. package/build/store/selectors.js +131 -6
  83. package/build/store/selectors.js.map +1 -1
  84. package/build/store/utils.js +27 -0
  85. package/build/store/utils.js.map +1 -0
  86. package/build-module/components/block-alignment-control/ui.js +2 -2
  87. package/build-module/components/block-alignment-control/ui.js.map +1 -1
  88. package/build-module/components/block-content-overlay/index.js +13 -4
  89. package/build-module/components/block-content-overlay/index.js.map +1 -1
  90. package/build-module/components/block-list/block.native.js +3 -1
  91. package/build-module/components/block-list/block.native.js.map +1 -1
  92. package/build-module/components/block-lock/index.js +1 -0
  93. package/build-module/components/block-lock/index.js.map +1 -1
  94. package/build-module/components/block-lock/menu-item.js +4 -18
  95. package/build-module/components/block-lock/menu-item.js.map +1 -1
  96. package/build-module/components/block-lock/modal.js +31 -12
  97. package/build-module/components/block-lock/modal.js.map +1 -1
  98. package/build-module/components/block-lock/toolbar.js +6 -18
  99. package/build-module/components/block-lock/toolbar.js.map +1 -1
  100. package/build-module/components/block-lock/use-block-lock.js +41 -0
  101. package/build-module/components/block-lock/use-block-lock.js.map +1 -0
  102. package/build-module/components/block-mover/button.js +5 -5
  103. package/build-module/components/block-mover/button.js.map +1 -1
  104. package/build-module/components/block-mover/index.js +38 -63
  105. package/build-module/components/block-mover/index.js.map +1 -1
  106. package/build-module/components/block-pattern-setup/index.js +39 -24
  107. package/build-module/components/block-pattern-setup/index.js.map +1 -1
  108. package/build-module/components/block-pattern-setup/setup-toolbar.js +1 -1
  109. package/build-module/components/block-pattern-setup/setup-toolbar.js.map +1 -1
  110. package/build-module/components/block-popover/inbetween.js +165 -0
  111. package/build-module/components/block-popover/inbetween.js.map +1 -0
  112. package/build-module/components/block-popover/index.js +67 -0
  113. package/build-module/components/block-popover/index.js.map +1 -0
  114. package/build-module/components/{block-tools → block-popover}/use-popover-scroll.js +3 -1
  115. package/build-module/components/block-popover/use-popover-scroll.js.map +1 -0
  116. package/build-module/components/block-preview/auto.js +6 -3
  117. package/build-module/components/block-preview/auto.js.map +1 -1
  118. package/build-module/components/block-preview/index.js +4 -2
  119. package/build-module/components/block-preview/index.js.map +1 -1
  120. package/build-module/components/block-styles/index.js +1 -9
  121. package/build-module/components/block-styles/index.js.map +1 -1
  122. package/build-module/components/block-switcher/index.js +7 -2
  123. package/build-module/components/block-switcher/index.js.map +1 -1
  124. package/build-module/components/block-tools/back-compat.js +1 -1
  125. package/build-module/components/block-tools/back-compat.js.map +1 -1
  126. package/build-module/components/block-tools/block-selection-button.js +3 -2
  127. package/build-module/components/block-tools/block-selection-button.js.map +1 -1
  128. package/build-module/components/block-tools/index.js +3 -3
  129. package/build-module/components/block-tools/index.js.map +1 -1
  130. package/build-module/components/block-tools/insertion-point.js +16 -121
  131. package/build-module/components/block-tools/insertion-point.js.map +1 -1
  132. package/build-module/components/block-tools/{block-popover.js → selected-block-popover.js} +25 -105
  133. package/build-module/components/block-tools/selected-block-popover.js.map +1 -0
  134. package/build-module/components/copy-handler/index.js +44 -9
  135. package/build-module/components/copy-handler/index.js.map +1 -1
  136. package/build-module/components/duotone-control/index.js +4 -1
  137. package/build-module/components/duotone-control/index.js.map +1 -1
  138. package/build-module/components/inserter/index.native.js +31 -10
  139. package/build-module/components/inserter/index.native.js.map +1 -1
  140. package/build-module/components/link-control/index.js +6 -7
  141. package/build-module/components/link-control/index.js.map +1 -1
  142. package/build-module/components/list-view/block-select-button.js +4 -9
  143. package/build-module/components/list-view/block-select-button.js.map +1 -1
  144. package/build-module/components/list-view/block.js +13 -2
  145. package/build-module/components/list-view/block.js.map +1 -1
  146. package/build-module/components/rich-text/index.js +0 -4
  147. package/build-module/components/rich-text/index.js.map +1 -1
  148. package/build-module/components/rich-text/index.native.js +0 -4
  149. package/build-module/components/rich-text/index.native.js.map +1 -1
  150. package/build-module/components/use-block-display-information/index.js +3 -1
  151. package/build-module/components/use-block-display-information/index.js.map +1 -1
  152. package/build-module/hooks/border.js +458 -44
  153. package/build-module/hooks/border.js.map +1 -1
  154. package/build-module/hooks/duotone.js +63 -16
  155. package/build-module/hooks/duotone.js.map +1 -1
  156. package/build-module/hooks/index.js +2 -1
  157. package/build-module/hooks/index.js.map +1 -1
  158. package/build-module/hooks/use-border-props.js +21 -30
  159. package/build-module/hooks/use-border-props.js.map +1 -1
  160. package/build-module/index.js +1 -1
  161. package/build-module/index.js.map +1 -1
  162. package/build-module/store/actions.js +19 -16
  163. package/build-module/store/actions.js.map +1 -1
  164. package/build-module/store/reducer.js +0 -24
  165. package/build-module/store/reducer.js.map +1 -1
  166. package/build-module/store/selectors.js +120 -5
  167. package/build-module/store/selectors.js.map +1 -1
  168. package/build-module/store/utils.js +20 -0
  169. package/build-module/store/utils.js.map +1 -0
  170. package/build-style/style-rtl.css +145 -272
  171. package/build-style/style.css +145 -272
  172. package/package.json +28 -28
  173. package/src/components/block-alignment-control/ui.js +2 -2
  174. package/src/components/block-content-overlay/index.js +19 -2
  175. package/src/components/block-list/block.native.js +2 -0
  176. package/src/components/block-lock/index.js +1 -0
  177. package/src/components/block-lock/menu-item.js +3 -23
  178. package/src/components/block-lock/modal.js +37 -13
  179. package/src/components/block-lock/style.scss +1 -2
  180. package/src/components/block-lock/toolbar.js +4 -21
  181. package/src/components/block-lock/use-block-lock.js +45 -0
  182. package/src/components/block-mover/button.js +5 -7
  183. package/src/components/block-mover/index.js +37 -60
  184. package/src/components/block-mover/stories/index.js +110 -0
  185. package/src/components/block-mover/style.scss +48 -138
  186. package/src/components/block-pattern-setup/index.js +84 -59
  187. package/src/components/block-pattern-setup/setup-toolbar.js +3 -1
  188. package/src/components/block-pattern-setup/style.scss +32 -26
  189. package/src/components/block-popover/README.md +41 -0
  190. package/src/components/block-popover/inbetween.js +180 -0
  191. package/src/components/block-popover/index.js +73 -0
  192. package/src/components/block-popover/style.scss +24 -0
  193. package/src/components/{block-tools → block-popover}/use-popover-scroll.js +3 -1
  194. package/src/components/block-preview/auto.js +10 -1
  195. package/src/components/block-preview/index.js +2 -0
  196. package/src/components/block-styles/index.js +1 -12
  197. package/src/components/block-switcher/index.js +13 -1
  198. package/src/components/block-switcher/style.scss +4 -4
  199. package/src/components/block-switcher/test/__snapshots__/index.js.snap +15 -13
  200. package/src/components/block-toolbar/style.scss +0 -12
  201. package/src/components/block-tools/back-compat.js +1 -1
  202. package/src/components/block-tools/block-selection-button.js +3 -1
  203. package/src/components/block-tools/index.js +6 -4
  204. package/src/components/block-tools/insertion-point.js +19 -152
  205. package/src/components/block-tools/{block-popover.js → selected-block-popover.js} +24 -116
  206. package/src/components/block-tools/style.scss +11 -123
  207. package/src/components/border-radius-control/style.scss +5 -2
  208. package/src/components/copy-handler/index.js +52 -10
  209. package/src/components/default-block-appender/style.scss +1 -2
  210. package/src/components/duotone-control/index.js +8 -1
  211. package/src/components/gradients/README.md +29 -0
  212. package/src/components/inserter/index.native.js +60 -25
  213. package/src/components/inserter/style.native.scss +24 -3
  214. package/src/components/link-control/index.js +5 -5
  215. package/src/components/list-view/block-select-button.js +2 -10
  216. package/src/components/list-view/block.js +16 -7
  217. package/src/components/navigable-toolbar/README.md +16 -0
  218. package/src/components/rich-text/index.js +0 -2
  219. package/src/components/rich-text/index.native.js +0 -4
  220. package/src/components/use-block-display-information/index.js +2 -0
  221. package/src/hooks/border.js +438 -72
  222. package/src/hooks/border.scss +48 -0
  223. package/src/hooks/duotone.js +98 -62
  224. package/src/hooks/index.js +2 -1
  225. package/src/hooks/use-border-props.js +15 -32
  226. package/src/index.js +1 -0
  227. package/src/store/actions.js +19 -15
  228. package/src/store/reducer.js +0 -21
  229. package/src/store/selectors.js +160 -5
  230. package/src/store/test/actions.js +0 -18
  231. package/src/store/test/reducer.js +0 -19
  232. package/src/store/test/selectors.js +0 -19
  233. package/src/store/utils.js +19 -0
  234. package/src/style.scss +1 -1
  235. package/build/components/block-mobile-toolbar/index.js +0 -42
  236. package/build/components/block-mobile-toolbar/index.js.map +0 -1
  237. package/build/components/block-tools/block-popover.js.map +0 -1
  238. package/build/components/block-tools/use-popover-scroll.js.map +0 -1
  239. package/build/components/list-view/appender.js +0 -93
  240. package/build/components/list-view/appender.js.map +0 -1
  241. package/build/components/list-view/list-item.js +0 -62
  242. package/build/components/list-view/list-item.js.map +0 -1
  243. package/build/components/rich-text/use-caret-in-format.js +0 -43
  244. package/build/components/rich-text/use-caret-in-format.js.map +0 -1
  245. package/build/hooks/border-color.js +0 -302
  246. package/build/hooks/border-color.js.map +0 -1
  247. package/build/hooks/border-style.js +0 -96
  248. package/build/hooks/border-style.js.map +0 -1
  249. package/build/hooks/border-width.js +0 -162
  250. package/build/hooks/border-width.js.map +0 -1
  251. package/build-module/components/block-mobile-toolbar/index.js +0 -31
  252. package/build-module/components/block-mobile-toolbar/index.js.map +0 -1
  253. package/build-module/components/block-tools/block-popover.js.map +0 -1
  254. package/build-module/components/block-tools/use-popover-scroll.js.map +0 -1
  255. package/build-module/components/list-view/appender.js +0 -76
  256. package/build-module/components/list-view/appender.js.map +0 -1
  257. package/build-module/components/list-view/list-item.js +0 -47
  258. package/build-module/components/list-view/list-item.js.map +0 -1
  259. package/build-module/components/rich-text/use-caret-in-format.js +0 -33
  260. package/build-module/components/rich-text/use-caret-in-format.js.map +0 -1
  261. package/build-module/hooks/border-color.js +0 -276
  262. package/build-module/hooks/border-color.js.map +0 -1
  263. package/build-module/hooks/border-style.js +0 -78
  264. package/build-module/hooks/border-style.js.map +0 -1
  265. package/build-module/hooks/border-width.js +0 -143
  266. package/build-module/hooks/border-width.js.map +0 -1
  267. package/src/components/block-mobile-toolbar/index.js +0 -24
  268. package/src/components/block-mobile-toolbar/style.scss +0 -29
  269. package/src/components/list-view/appender.js +0 -82
  270. package/src/components/list-view/list-item.js +0 -59
  271. package/src/components/rich-text/use-caret-in-format.js +0 -28
  272. package/src/hooks/border-color.js +0 -315
  273. package/src/hooks/border-style.js +0 -64
  274. package/src/hooks/border-width.js +0 -139
@@ -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
  }
@@ -11,7 +11,7 @@ import {
11
11
  } from '@wordpress/components';
12
12
 
13
13
  import { useState } from '@wordpress/element';
14
- import { useInstanceId } from '@wordpress/compose';
14
+ import { useInstanceId, useResizeObserver } from '@wordpress/compose';
15
15
  import { __ } from '@wordpress/i18n';
16
16
 
17
17
  /**
@@ -28,6 +28,7 @@ const SetupContent = ( {
28
28
  activeSlide,
29
29
  patterns,
30
30
  onBlockPatternSelect,
31
+ height,
31
32
  } ) => {
32
33
  const composite = useCompositeState();
33
34
  const containerClass = 'block-editor-block-pattern-setup__container';
@@ -38,41 +39,52 @@ const SetupContent = ( {
38
39
  [ activeSlide + 1, 'next-slide' ],
39
40
  ] );
40
41
  return (
41
- <div className={ containerClass }>
42
- <ul className="carousel-container">
43
- { patterns.map( ( pattern, index ) => (
44
- <BlockPatternSlide
45
- className={ slideClass.get( index ) || '' }
46
- key={ pattern.name }
47
- pattern={ pattern }
48
- />
49
- ) ) }
50
- </ul>
42
+ <div
43
+ className="block-editor-block-pattern-setup__carousel"
44
+ style={ { height } }
45
+ >
46
+ <div className={ containerClass }>
47
+ <ul className="carousel-container">
48
+ { patterns.map( ( pattern, index ) => (
49
+ <BlockPatternSlide
50
+ className={ slideClass.get( index ) || '' }
51
+ key={ pattern.name }
52
+ pattern={ pattern }
53
+ minHeight={ height }
54
+ />
55
+ ) ) }
56
+ </ul>
57
+ </div>
51
58
  </div>
52
59
  );
53
60
  }
54
61
  return (
55
- <Composite
56
- { ...composite }
57
- role="listbox"
58
- className={ containerClass }
59
- aria-label={ __( 'Patterns list' ) }
62
+ <div
63
+ style={ { height } }
64
+ className="block-editor-block-pattern-setup__grid"
60
65
  >
61
- { patterns.map( ( pattern ) => (
62
- <BlockPattern
63
- key={ pattern.name }
64
- pattern={ pattern }
65
- onSelect={ onBlockPatternSelect }
66
- composite={ composite }
67
- />
68
- ) ) }
69
- </Composite>
66
+ <Composite
67
+ { ...composite }
68
+ role="listbox"
69
+ className={ containerClass }
70
+ aria-label={ __( 'Patterns list' ) }
71
+ >
72
+ { patterns.map( ( pattern ) => (
73
+ <BlockPattern
74
+ key={ pattern.name }
75
+ pattern={ pattern }
76
+ onSelect={ onBlockPatternSelect }
77
+ composite={ composite }
78
+ />
79
+ ) ) }
80
+ </Composite>
81
+ </div>
70
82
  );
71
83
  };
72
84
 
73
85
  function BlockPattern( { pattern, onSelect, composite } ) {
74
86
  const baseClassName = 'block-editor-block-pattern-setup-list';
75
- const { blocks, title, description, viewportWidth = 700 } = pattern;
87
+ const { blocks, description, viewportWidth = 700 } = pattern;
76
88
  const descriptionId = useInstanceId(
77
89
  BlockPattern,
78
90
  `${ baseClassName }__item-description`
@@ -94,9 +106,6 @@ function BlockPattern( { pattern, onSelect, composite } ) {
94
106
  blocks={ blocks }
95
107
  viewportWidth={ viewportWidth }
96
108
  />
97
- <div className={ `${ baseClassName }__item-title` }>
98
- { title }
99
- </div>
100
109
  </CompositeItem>
101
110
  { !! description && (
102
111
  <VisuallyHidden id={ descriptionId }>
@@ -107,7 +116,7 @@ function BlockPattern( { pattern, onSelect, composite } ) {
107
116
  );
108
117
  }
109
118
 
110
- function BlockPatternSlide( { className, pattern } ) {
119
+ function BlockPatternSlide( { className, pattern, minHeight } ) {
111
120
  const { blocks, title, description } = pattern;
112
121
  const descriptionId = useInstanceId(
113
122
  BlockPatternSlide,
@@ -119,7 +128,10 @@ function BlockPatternSlide( { className, pattern } ) {
119
128
  aria-label={ title }
120
129
  aria-describedby={ description ? descriptionId : undefined }
121
130
  >
122
- <BlockPreview blocks={ blocks } __experimentalLive />
131
+ <BlockPreview
132
+ blocks={ blocks }
133
+ __experimentalMinHeight={ minHeight }
134
+ />
123
135
  { !! description && (
124
136
  <VisuallyHidden id={ descriptionId }>
125
137
  { description }
@@ -141,6 +153,10 @@ const BlockPatternSetup = ( {
141
153
  const [ showBlank, setShowBlank ] = useState( false );
142
154
  const { replaceBlock } = useDispatch( blockEditorStore );
143
155
  const patterns = usePatternsSetup( clientId, blockName, filterPatternsFn );
156
+ const [
157
+ contentResizeListener,
158
+ { height: contentHeight },
159
+ ] = useResizeObserver();
144
160
 
145
161
  if ( ! patterns?.length || showBlank ) {
146
162
  return startBlankComponent;
@@ -152,35 +168,44 @@ const BlockPatternSetup = ( {
152
168
  };
153
169
  const onPatternSelectCallback =
154
170
  onBlockPatternSelect || onBlockPatternSelectDefault;
171
+ const onStartBlank = startBlankComponent
172
+ ? () => {
173
+ setShowBlank( true );
174
+ }
175
+ : undefined;
155
176
  return (
156
- <div
157
- className={ `block-editor-block-pattern-setup view-mode-${ viewMode }` }
158
- >
159
- <SetupToolbar
160
- viewMode={ viewMode }
161
- setViewMode={ setViewMode }
162
- activeSlide={ activeSlide }
163
- totalSlides={ patterns.length }
164
- handleNext={ () => {
165
- setActiveSlide( ( active ) => active + 1 );
166
- } }
167
- handlePrevious={ () => {
168
- setActiveSlide( ( active ) => active - 1 );
169
- } }
170
- onBlockPatternSelect={ () => {
171
- onPatternSelectCallback( patterns[ activeSlide ].blocks );
172
- } }
173
- onStartBlank={ () => {
174
- setShowBlank( true );
175
- } }
176
- />
177
- <SetupContent
178
- viewMode={ viewMode }
179
- activeSlide={ activeSlide }
180
- patterns={ patterns }
181
- onBlockPatternSelect={ onPatternSelectCallback }
182
- />
183
- </div>
177
+ <>
178
+ { contentResizeListener }
179
+ <div
180
+ className={ `block-editor-block-pattern-setup view-mode-${ viewMode }` }
181
+ >
182
+ <SetupContent
183
+ viewMode={ viewMode }
184
+ activeSlide={ activeSlide }
185
+ patterns={ patterns }
186
+ onBlockPatternSelect={ onPatternSelectCallback }
187
+ height={ contentHeight - 2 * 60 }
188
+ />
189
+ <SetupToolbar
190
+ viewMode={ viewMode }
191
+ setViewMode={ setViewMode }
192
+ activeSlide={ activeSlide }
193
+ totalSlides={ patterns.length }
194
+ handleNext={ () => {
195
+ setActiveSlide( ( active ) => active + 1 );
196
+ } }
197
+ handlePrevious={ () => {
198
+ setActiveSlide( ( active ) => active - 1 );
199
+ } }
200
+ onBlockPatternSelect={ () => {
201
+ onPatternSelectCallback(
202
+ patterns[ activeSlide ].blocks
203
+ );
204
+ } }
205
+ onStartBlank={ onStartBlank }
206
+ />
207
+ </div>
208
+ </>
184
209
  );
185
210
  };
186
211
 
@@ -17,7 +17,9 @@ import { VIEWMODES } from './constants';
17
17
 
18
18
  const Actions = ( { onStartBlank, onBlockPatternSelect } ) => (
19
19
  <div className="block-editor-block-pattern-setup__actions">
20
- <Button onClick={ onStartBlank }>{ __( 'Start blank' ) }</Button>
20
+ { onStartBlank && (
21
+ <Button onClick={ onStartBlank }>{ __( 'Start blank' ) }</Button>
22
+ ) }
21
23
  <Button variant="primary" onClick={ onBlockPatternSelect }>
22
24
  { __( 'Choose' ) }
23
25
  </Button>
@@ -5,8 +5,6 @@
5
5
  align-items: flex-start;
6
6
  width: 100%;
7
7
  border-radius: $radius-block-ui;
8
- box-shadow: inset 0 0 0 $border-width $gray-900;
9
- outline: 1px solid transparent; // Shown for Windows 10 High Contrast mode.
10
8
 
11
9
  // TODO change to check parent.
12
10
  &.view-mode-grid {
@@ -15,37 +13,41 @@
15
13
  }
16
14
 
17
15
  .block-editor-block-pattern-setup__container {
18
- display: grid;
19
- grid-template-columns: 1fr 1fr;
20
- grid-gap: $grid-unit-20;
21
- padding: $grid-unit-20;
22
- max-height: 550px;
23
- overflow: auto;
24
- margin: 0 $border-width $border-width $border-width;
25
- width: calc(100% - #{ $border-width * 2 });
26
- background: $white;
16
+ column-gap: $grid-unit-30;
17
+ display: block;
18
+ width: 100%;
19
+ padding: $grid-unit-40;
20
+ column-count: 2;
21
+
22
+ @include break-huge() {
23
+ column-count: 3;
24
+ }
27
25
 
28
26
  .block-editor-block-preview__container,
29
27
  div[role="button"] {
30
28
  cursor: pointer;
31
29
  }
32
30
 
33
- .block-editor-block-pattern-setup-list__item-title {
34
- padding: $grid-unit-05;
35
- font-size: $helptext-font-size;
36
- text-align: center;
37
- }
31
+ .block-editor-block-pattern-setup-list__list-item {
32
+ break-inside: avoid-column;
33
+ margin-bottom: $grid-unit-30;
34
+
35
+ .block-editor-block-preview__container {
36
+ min-height: 100px;
37
+ border-radius: $radius-block-ui;
38
+ border: $border-width solid $gray-300;
39
+ }
38
40
 
39
- .block-editor-block-preview__container {
40
- border-radius: $radius-block-ui;
41
- border: $border-width solid $gray-300;
41
+ .block-editor-block-preview__content {
42
+ width: 100%;
43
+ }
42
44
  }
43
45
  }
44
46
  }
45
47
 
46
48
  .block-editor-block-pattern-setup__toolbar {
49
+ height: $header-height;
47
50
  box-sizing: border-box;
48
- position: relative;
49
51
  padding: $grid-unit-20;
50
52
  width: 100%;
51
53
  text-align: left;
@@ -54,13 +56,12 @@
54
56
  // Block UI appearance.
55
57
  border-radius: $radius-block-ui $radius-block-ui 0 0;
56
58
  background-color: $white;
57
- box-shadow: inset 0 0 0 $border-width $gray-900;
58
- outline: 1px solid transparent; // Shown for Windows 10 High Contrast mode.
59
-
60
59
  display: flex;
61
60
  flex-direction: row;
62
61
  align-items: center;
63
62
  justify-content: space-between;
63
+ border-top: 1px solid $gray-300;
64
+ align-self: flex-end;
64
65
 
65
66
  .block-editor-block-pattern-setup__display-controls {
66
67
  display: flex;
@@ -93,13 +94,12 @@
93
94
  box-sizing: border-box;
94
95
  }
95
96
  .pattern-slide {
96
- opacity: 0;
97
97
  position: absolute;
98
98
  top: 0;
99
99
  width: 100%;
100
100
  margin: auto;
101
- padding: $grid-unit-20;
102
- transition: transform 0.5s, opacity 0.5s, z-index 0.5s;
101
+ padding: 0;
102
+ transition: transform 0.5s, z-index 0.5s;
103
103
  z-index: z-index(".block-editor-block-pattern-setup .pattern-slide");
104
104
 
105
105
  &.active-slide {
@@ -125,3 +125,9 @@
125
125
  }
126
126
  }
127
127
  }
128
+
129
+ .block-editor-block-pattern-setup__carousel,
130
+ .block-editor-block-pattern-setup__grid {
131
+ width: 100%;
132
+ overflow-y: auto;
133
+ }
@@ -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