@wordpress/block-editor 13.1.0 → 13.2.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 (142) hide show
  1. package/CHANGELOG.md +19 -17
  2. package/README.md +1 -1
  3. package/build/components/block-lock/modal.js +67 -67
  4. package/build/components/block-lock/modal.js.map +1 -1
  5. package/build/components/block-mover/index.js +12 -6
  6. package/build/components/block-mover/index.js.map +1 -1
  7. package/build/components/block-toolbar/shuffle.js +3 -1
  8. package/build/components/block-toolbar/shuffle.js.map +1 -1
  9. package/build/components/child-layout-control/index.js +185 -127
  10. package/build/components/child-layout-control/index.js.map +1 -1
  11. package/build/components/global-styles/use-global-styles-output.js +4 -3
  12. package/build/components/global-styles/use-global-styles-output.js.map +1 -1
  13. package/build/components/grid/grid-item-movers.js +97 -0
  14. package/build/components/grid/grid-item-movers.js.map +1 -0
  15. package/build/components/{grid-visualizer → grid}/grid-item-resizer.js +18 -56
  16. package/build/components/grid/grid-item-resizer.js.map +1 -0
  17. package/build/components/grid/grid-visualizer.js +225 -0
  18. package/build/components/grid/grid-visualizer.js.map +1 -0
  19. package/build/components/{grid-visualizer → grid}/index.js +14 -0
  20. package/build/components/grid/index.js.map +1 -0
  21. package/build/components/grid/use-get-number-of-blocks-before-cell.js +40 -0
  22. package/build/components/grid/use-get-number-of-blocks-before-cell.js.map +1 -0
  23. package/build/components/grid/use-grid-layout-sync.js +162 -0
  24. package/build/components/grid/use-grid-layout-sync.js.map +1 -0
  25. package/build/components/grid/utils.js +145 -0
  26. package/build/components/grid/utils.js.map +1 -0
  27. package/build/components/image-editor/aspect-ratio-dropdown.js +0 -1
  28. package/build/components/image-editor/aspect-ratio-dropdown.js.map +1 -1
  29. package/build/components/inner-blocks/index.js +1 -1
  30. package/build/components/inner-blocks/index.js.map +1 -1
  31. package/build/components/rich-text/event-listeners/input-rules.js +1 -0
  32. package/build/components/rich-text/event-listeners/input-rules.js.map +1 -1
  33. package/build/components/rich-text/index.native.js +10 -4
  34. package/build/components/rich-text/index.native.js.map +1 -1
  35. package/build/components/rich-text/native/index.native.js +14 -0
  36. package/build/components/rich-text/native/index.native.js.map +1 -1
  37. package/build/hooks/block-style-variation.js +26 -7
  38. package/build/hooks/block-style-variation.js.map +1 -1
  39. package/build/hooks/layout-child.js +29 -21
  40. package/build/hooks/layout-child.js.map +1 -1
  41. package/build/hooks/utils.js +3 -2
  42. package/build/hooks/utils.js.map +1 -1
  43. package/build/layouts/grid.js +24 -47
  44. package/build/layouts/grid.js.map +1 -1
  45. package/build/lock-unlock.js +1 -1
  46. package/build/lock-unlock.js.map +1 -1
  47. package/build/store/actions.js +17 -1
  48. package/build/store/actions.js.map +1 -1
  49. package/build-module/components/block-lock/modal.js +67 -67
  50. package/build-module/components/block-lock/modal.js.map +1 -1
  51. package/build-module/components/block-mover/index.js +12 -6
  52. package/build-module/components/block-mover/index.js.map +1 -1
  53. package/build-module/components/block-toolbar/shuffle.js +3 -1
  54. package/build-module/components/block-toolbar/shuffle.js.map +1 -1
  55. package/build-module/components/child-layout-control/index.js +185 -127
  56. package/build-module/components/child-layout-control/index.js.map +1 -1
  57. package/build-module/components/global-styles/use-global-styles-output.js +4 -3
  58. package/build-module/components/global-styles/use-global-styles-output.js.map +1 -1
  59. package/build-module/components/grid/grid-item-movers.js +90 -0
  60. package/build-module/components/grid/grid-item-movers.js.map +1 -0
  61. package/build-module/components/{grid-visualizer → grid}/grid-item-resizer.js +13 -51
  62. package/build-module/components/grid/grid-item-resizer.js.map +1 -0
  63. package/build-module/components/grid/grid-visualizer.js +217 -0
  64. package/build-module/components/grid/grid-visualizer.js.map +1 -0
  65. package/build-module/components/grid/index.js +5 -0
  66. package/build-module/components/grid/index.js.map +1 -0
  67. package/build-module/components/grid/use-get-number-of-blocks-before-cell.js +33 -0
  68. package/build-module/components/grid/use-get-number-of-blocks-before-cell.js.map +1 -0
  69. package/build-module/components/grid/use-grid-layout-sync.js +155 -0
  70. package/build-module/components/grid/use-grid-layout-sync.js.map +1 -0
  71. package/build-module/components/grid/utils.js +131 -0
  72. package/build-module/components/grid/utils.js.map +1 -0
  73. package/build-module/components/image-editor/aspect-ratio-dropdown.js +0 -1
  74. package/build-module/components/image-editor/aspect-ratio-dropdown.js.map +1 -1
  75. package/build-module/components/inner-blocks/index.js +1 -1
  76. package/build-module/components/inner-blocks/index.js.map +1 -1
  77. package/build-module/components/rich-text/event-listeners/input-rules.js +1 -1
  78. package/build-module/components/rich-text/event-listeners/input-rules.js.map +1 -1
  79. package/build-module/components/rich-text/index.native.js +11 -5
  80. package/build-module/components/rich-text/index.native.js.map +1 -1
  81. package/build-module/components/rich-text/native/index.native.js +14 -0
  82. package/build-module/components/rich-text/native/index.native.js.map +1 -1
  83. package/build-module/hooks/block-style-variation.js +25 -7
  84. package/build-module/hooks/block-style-variation.js.map +1 -1
  85. package/build-module/hooks/layout-child.js +27 -19
  86. package/build-module/hooks/layout-child.js.map +1 -1
  87. package/build-module/hooks/utils.js +3 -2
  88. package/build-module/hooks/utils.js.map +1 -1
  89. package/build-module/layouts/grid.js +24 -47
  90. package/build-module/layouts/grid.js.map +1 -1
  91. package/build-module/lock-unlock.js +1 -1
  92. package/build-module/lock-unlock.js.map +1 -1
  93. package/build-module/store/actions.js +17 -1
  94. package/build-module/store/actions.js.map +1 -1
  95. package/build-style/style-rtl.css +39 -18
  96. package/build-style/style.css +39 -18
  97. package/package.json +31 -31
  98. package/src/components/block-lock/modal.js +95 -82
  99. package/src/components/block-lock/style.scss +11 -1
  100. package/src/components/block-mover/index.js +37 -24
  101. package/src/components/block-toolbar/shuffle.js +3 -1
  102. package/src/components/child-layout-control/index.js +224 -159
  103. package/src/components/global-styles/test/use-global-styles-output.js +38 -3
  104. package/src/components/global-styles/use-global-styles-output.js +4 -3
  105. package/src/components/grid/grid-item-movers.js +128 -0
  106. package/src/components/{grid-visualizer → grid}/grid-item-resizer.js +14 -52
  107. package/src/components/grid/grid-visualizer.js +267 -0
  108. package/src/components/grid/index.js +4 -0
  109. package/src/components/grid/style.scss +63 -0
  110. package/src/components/grid/use-get-number-of-blocks-before-cell.js +30 -0
  111. package/src/components/grid/use-grid-layout-sync.js +167 -0
  112. package/src/components/grid/utils.js +178 -0
  113. package/src/components/image-editor/aspect-ratio-dropdown.js +0 -1
  114. package/src/components/inner-blocks/index.js +3 -1
  115. package/src/components/rich-text/event-listeners/input-rules.js +1 -1
  116. package/src/components/rich-text/index.native.js +10 -8
  117. package/src/components/rich-text/native/index.native.js +17 -0
  118. package/src/hooks/block-style-variation.js +24 -6
  119. package/src/hooks/layout-child.js +34 -14
  120. package/src/hooks/utils.js +3 -1
  121. package/src/layouts/grid.js +54 -62
  122. package/src/lock-unlock.js +1 -1
  123. package/src/store/actions.js +21 -1
  124. package/src/style.scss +1 -1
  125. package/build/components/grid-visualizer/grid-item-resizer.js.map +0 -1
  126. package/build/components/grid-visualizer/grid-visualizer.js +0 -92
  127. package/build/components/grid-visualizer/grid-visualizer.js.map +0 -1
  128. package/build/components/grid-visualizer/index.js.map +0 -1
  129. package/build/components/grid-visualizer/utils.js +0 -10
  130. package/build/components/grid-visualizer/utils.js.map +0 -1
  131. package/build-module/components/grid-visualizer/grid-item-resizer.js.map +0 -1
  132. package/build-module/components/grid-visualizer/grid-visualizer.js +0 -84
  133. package/build-module/components/grid-visualizer/grid-visualizer.js.map +0 -1
  134. package/build-module/components/grid-visualizer/index.js +0 -3
  135. package/build-module/components/grid-visualizer/index.js.map +0 -1
  136. package/build-module/components/grid-visualizer/utils.js +0 -4
  137. package/build-module/components/grid-visualizer/utils.js.map +0 -1
  138. package/src/components/grid-visualizer/grid-visualizer.js +0 -101
  139. package/src/components/grid-visualizer/index.js +0 -2
  140. package/src/components/grid-visualizer/style.scss +0 -34
  141. package/src/components/grid-visualizer/utils.js +0 -5
  142. /package/src/components/font-sizes/{README.MD → README.md} +0 -0
@@ -14,6 +14,13 @@ import {
14
14
  } from '@wordpress/components';
15
15
  import { __ } from '@wordpress/i18n';
16
16
  import { useEffect } from '@wordpress/element';
17
+ import { useSelect, useDispatch } from '@wordpress/data';
18
+
19
+ /**
20
+ * Internal dependencies
21
+ */
22
+ import { useGetNumberOfBlocksBeforeCell } from '../grid/use-get-number-of-blocks-before-cell';
23
+ import { store as blockEditorStore } from '../../store';
17
24
 
18
25
  function helpText( selfStretch, parentLayout ) {
19
26
  const { orientation = 'horizontal' } = parentLayout;
@@ -48,21 +55,46 @@ export default function ChildLayoutControl( {
48
55
  isShownByDefault,
49
56
  panelId,
50
57
  } ) {
51
- const {
52
- selfStretch,
53
- flexSize,
54
- columnStart,
55
- rowStart,
56
- columnSpan,
57
- rowSpan,
58
- } = childLayout;
59
58
  const {
60
59
  type: parentType,
61
60
  default: { type: defaultParentType = 'default' } = {},
62
- orientation = 'horizontal',
63
61
  } = parentLayout ?? {};
64
62
  const parentLayoutType = parentType || defaultParentType;
65
63
 
64
+ if ( parentLayoutType === 'flex' ) {
65
+ return (
66
+ <FlexControls
67
+ childLayout={ childLayout }
68
+ onChange={ onChange }
69
+ parentLayout={ parentLayout }
70
+ isShownByDefault={ isShownByDefault }
71
+ panelId={ panelId }
72
+ />
73
+ );
74
+ } else if ( parentLayoutType === 'grid' ) {
75
+ return (
76
+ <GridControls
77
+ childLayout={ childLayout }
78
+ onChange={ onChange }
79
+ parentLayout={ parentLayout }
80
+ isShownByDefault={ isShownByDefault }
81
+ panelId={ panelId }
82
+ />
83
+ );
84
+ }
85
+
86
+ return null;
87
+ }
88
+
89
+ function FlexControls( {
90
+ childLayout,
91
+ onChange,
92
+ parentLayout,
93
+ isShownByDefault,
94
+ panelId,
95
+ } ) {
96
+ const { selfStretch, flexSize } = childLayout;
97
+ const { orientation = 'horizontal' } = parentLayout ?? {};
66
98
  const hasFlexValue = () => !! selfStretch;
67
99
  const flexResetLabel =
68
100
  orientation === 'horizontal' ? __( 'Width' ) : __( 'Height' );
@@ -73,6 +105,96 @@ export default function ChildLayoutControl( {
73
105
  } );
74
106
  };
75
107
 
108
+ useEffect( () => {
109
+ if ( selfStretch === 'fixed' && ! flexSize ) {
110
+ onChange( {
111
+ ...childLayout,
112
+ selfStretch: 'fit',
113
+ } );
114
+ }
115
+ }, [] );
116
+
117
+ return (
118
+ <VStack
119
+ as={ ToolsPanelItem }
120
+ spacing={ 2 }
121
+ hasValue={ hasFlexValue }
122
+ label={ flexResetLabel }
123
+ onDeselect={ resetFlex }
124
+ isShownByDefault={ isShownByDefault }
125
+ panelId={ panelId }
126
+ >
127
+ <ToggleGroupControl
128
+ __nextHasNoMarginBottom
129
+ size="__unstable-large"
130
+ label={ childLayoutOrientation( parentLayout ) }
131
+ value={ selfStretch || 'fit' }
132
+ help={ helpText( selfStretch, parentLayout ) }
133
+ onChange={ ( value ) => {
134
+ const newFlexSize = value !== 'fixed' ? null : flexSize;
135
+ onChange( {
136
+ selfStretch: value,
137
+ flexSize: newFlexSize,
138
+ } );
139
+ } }
140
+ isBlock
141
+ >
142
+ <ToggleGroupControlOption
143
+ key="fit"
144
+ value="fit"
145
+ label={ __( 'Fit' ) }
146
+ />
147
+ <ToggleGroupControlOption
148
+ key="fill"
149
+ value="fill"
150
+ label={ __( 'Fill' ) }
151
+ />
152
+ <ToggleGroupControlOption
153
+ key="fixed"
154
+ value="fixed"
155
+ label={ __( 'Fixed' ) }
156
+ />
157
+ </ToggleGroupControl>
158
+ { selfStretch === 'fixed' && (
159
+ <UnitControl
160
+ size="__unstable-large"
161
+ onChange={ ( value ) => {
162
+ onChange( {
163
+ selfStretch,
164
+ flexSize: value,
165
+ } );
166
+ } }
167
+ value={ flexSize }
168
+ />
169
+ ) }
170
+ </VStack>
171
+ );
172
+ }
173
+
174
+ export function childLayoutOrientation( parentLayout ) {
175
+ const { orientation = 'horizontal' } = parentLayout;
176
+ return orientation === 'horizontal' ? __( 'Width' ) : __( 'Height' );
177
+ }
178
+
179
+ function GridControls( {
180
+ childLayout,
181
+ onChange,
182
+ parentLayout,
183
+ isShownByDefault,
184
+ panelId,
185
+ } ) {
186
+ const { columnStart, rowStart, columnSpan, rowSpan } = childLayout;
187
+ const { columnCount } = parentLayout ?? {};
188
+ const gridColumnNumber = parseInt( columnCount, 10 ) || 3;
189
+ const rootClientId = useSelect( ( select ) =>
190
+ select( blockEditorStore ).getBlockRootClientId( panelId )
191
+ );
192
+ const { moveBlocksToPosition, __unstableMarkNextChangeAsNotPersistent } =
193
+ useDispatch( blockEditorStore );
194
+ const getNumberOfBlocksBeforeCell = useGetNumberOfBlocksBeforeCell(
195
+ rootClientId,
196
+ gridColumnNumber
197
+ );
76
198
  const hasStartValue = () => !! columnStart || !! rowStart;
77
199
  const hasSpanValue = () => !! columnSpan || !! rowSpan;
78
200
  const resetGridStarts = () => {
@@ -88,184 +210,127 @@ export default function ChildLayoutControl( {
88
210
  } );
89
211
  };
90
212
 
91
- useEffect( () => {
92
- if ( selfStretch === 'fixed' && ! flexSize ) {
93
- onChange( {
94
- ...childLayout,
95
- selfStretch: 'fit',
96
- } );
97
- }
98
- }, [] );
99
-
100
213
  return (
101
214
  <>
102
- { parentLayoutType === 'flex' && (
103
- <VStack
215
+ <HStack
216
+ as={ ToolsPanelItem }
217
+ hasValue={ hasSpanValue }
218
+ label={ __( 'Grid span' ) }
219
+ onDeselect={ resetGridSpans }
220
+ isShownByDefault={ isShownByDefault }
221
+ panelId={ panelId }
222
+ >
223
+ <InputControl
224
+ size="__unstable-large"
225
+ label={ __( 'Column span' ) }
226
+ type="number"
227
+ onChange={ ( value ) => {
228
+ onChange( {
229
+ columnStart,
230
+ rowStart,
231
+ rowSpan,
232
+ columnSpan: value,
233
+ } );
234
+ } }
235
+ value={ columnSpan }
236
+ min={ 1 }
237
+ />
238
+ <InputControl
239
+ size="__unstable-large"
240
+ label={ __( 'Row span' ) }
241
+ type="number"
242
+ onChange={ ( value ) => {
243
+ onChange( {
244
+ columnStart,
245
+ rowStart,
246
+ columnSpan,
247
+ rowSpan: value,
248
+ } );
249
+ } }
250
+ value={ rowSpan }
251
+ min={ 1 }
252
+ />
253
+ </HStack>
254
+ { window.__experimentalEnableGridInteractivity && columnCount && (
255
+ // Use Flex with an explicit width on the FlexItem instead of HStack to
256
+ // work around an issue in webkit where inputs with a max attribute are
257
+ // sized incorrectly.
258
+ <Flex
104
259
  as={ ToolsPanelItem }
105
- spacing={ 2 }
106
- hasValue={ hasFlexValue }
107
- label={ flexResetLabel }
108
- onDeselect={ resetFlex }
109
- isShownByDefault={ isShownByDefault }
260
+ hasValue={ hasStartValue }
261
+ label={ __( 'Grid placement' ) }
262
+ onDeselect={ resetGridStarts }
263
+ isShownByDefault={ false }
110
264
  panelId={ panelId }
111
265
  >
112
- <ToggleGroupControl
113
- __nextHasNoMarginBottom
114
- size="__unstable-large"
115
- label={ childLayoutOrientation( parentLayout ) }
116
- value={ selfStretch || 'fit' }
117
- help={ helpText( selfStretch, parentLayout ) }
118
- onChange={ ( value ) => {
119
- const newFlexSize =
120
- value !== 'fixed' ? null : flexSize;
121
- onChange( {
122
- selfStretch: value,
123
- flexSize: newFlexSize,
124
- } );
125
- } }
126
- isBlock
127
- >
128
- <ToggleGroupControlOption
129
- key="fit"
130
- value="fit"
131
- label={ __( 'Fit' ) }
132
- />
133
- <ToggleGroupControlOption
134
- key="fill"
135
- value="fill"
136
- label={ __( 'Fill' ) }
137
- />
138
- <ToggleGroupControlOption
139
- key="fixed"
140
- value="fixed"
141
- label={ __( 'Fixed' ) }
142
- />
143
- </ToggleGroupControl>
144
- { selfStretch === 'fixed' && (
145
- <UnitControl
146
- size="__unstable-large"
147
- onChange={ ( value ) => {
148
- onChange( {
149
- selfStretch,
150
- flexSize: value,
151
- } );
152
- } }
153
- value={ flexSize }
154
- />
155
- ) }
156
- </VStack>
157
- ) }
158
- { parentLayoutType === 'grid' && (
159
- <>
160
- <HStack
161
- as={ ToolsPanelItem }
162
- hasValue={ hasSpanValue }
163
- label={ __( 'Grid span' ) }
164
- onDeselect={ resetGridSpans }
165
- isShownByDefault={ isShownByDefault }
166
- panelId={ panelId }
167
- >
266
+ <FlexItem style={ { width: '50%' } }>
168
267
  <InputControl
169
268
  size="__unstable-large"
170
- label={ __( 'Column span' ) }
269
+ label={ __( 'Column' ) }
171
270
  type="number"
172
271
  onChange={ ( value ) => {
173
272
  onChange( {
174
- columnStart,
273
+ columnStart: value,
175
274
  rowStart,
275
+ columnSpan,
176
276
  rowSpan,
177
- columnSpan: value,
178
277
  } );
278
+ __unstableMarkNextChangeAsNotPersistent();
279
+ moveBlocksToPosition(
280
+ [ panelId ],
281
+ rootClientId,
282
+ rootClientId,
283
+ getNumberOfBlocksBeforeCell(
284
+ value,
285
+ rowStart
286
+ )
287
+ );
179
288
  } }
180
- value={ columnSpan }
289
+ value={ columnStart }
181
290
  min={ 1 }
291
+ max={
292
+ gridColumnNumber
293
+ ? gridColumnNumber - ( columnSpan ?? 1 ) + 1
294
+ : undefined
295
+ }
182
296
  />
297
+ </FlexItem>
298
+ <FlexItem style={ { width: '50%' } }>
183
299
  <InputControl
184
300
  size="__unstable-large"
185
- label={ __( 'Row span' ) }
301
+ label={ __( 'Row' ) }
186
302
  type="number"
187
303
  onChange={ ( value ) => {
188
304
  onChange( {
189
305
  columnStart,
190
- rowStart,
306
+ rowStart: value,
191
307
  columnSpan,
192
- rowSpan: value,
308
+ rowSpan,
193
309
  } );
310
+ __unstableMarkNextChangeAsNotPersistent();
311
+ moveBlocksToPosition(
312
+ [ panelId ],
313
+ rootClientId,
314
+ rootClientId,
315
+ getNumberOfBlocksBeforeCell(
316
+ columnStart,
317
+ value
318
+ )
319
+ );
194
320
  } }
195
- value={ rowSpan }
321
+ value={ rowStart }
196
322
  min={ 1 }
323
+ max={
324
+ parentLayout?.rowCount
325
+ ? parentLayout.rowCount -
326
+ ( rowSpan ?? 1 ) +
327
+ 1
328
+ : undefined
329
+ }
197
330
  />
198
- </HStack>
199
- { window.__experimentalEnableGridInteractivity && (
200
- // Use Flex with an explicit width on the FlexItem instead of HStack to
201
- // work around an issue in webkit where inputs with a max attribute are
202
- // sized incorrectly.
203
- <Flex
204
- as={ ToolsPanelItem }
205
- hasValue={ hasStartValue }
206
- label={ __( 'Grid placement' ) }
207
- onDeselect={ resetGridStarts }
208
- isShownByDefault={ false }
209
- panelId={ panelId }
210
- >
211
- <FlexItem style={ { width: '50%' } }>
212
- <InputControl
213
- size="__unstable-large"
214
- label={ __( 'Column' ) }
215
- type="number"
216
- onChange={ ( value ) => {
217
- onChange( {
218
- columnStart: value,
219
- rowStart,
220
- columnSpan,
221
- rowSpan,
222
- } );
223
- } }
224
- value={ columnStart }
225
- min={ 1 }
226
- max={
227
- parentLayout?.columnCount
228
- ? parentLayout.columnCount -
229
- ( columnSpan ?? 1 ) +
230
- 1
231
- : undefined
232
- }
233
- />
234
- </FlexItem>
235
- <FlexItem style={ { width: '50%' } }>
236
- <InputControl
237
- size="__unstable-large"
238
- label={ __( 'Row' ) }
239
- type="number"
240
- onChange={ ( value ) => {
241
- onChange( {
242
- columnStart,
243
- rowStart: value,
244
- columnSpan,
245
- rowSpan,
246
- } );
247
- } }
248
- value={ rowStart }
249
- min={ 1 }
250
- max={
251
- parentLayout?.rowCount
252
- ? parentLayout.rowCount -
253
- ( rowSpan ?? 1 ) +
254
- 1
255
- : undefined
256
- }
257
- />
258
- </FlexItem>
259
- </Flex>
260
- ) }
261
- </>
331
+ </FlexItem>
332
+ </Flex>
262
333
  ) }
263
334
  </>
264
335
  );
265
336
  }
266
-
267
- export function childLayoutOrientation( parentLayout ) {
268
- const { orientation = 'horizontal' } = parentLayout;
269
-
270
- return orientation === 'horizontal' ? __( 'Width' ) : __( 'Height' );
271
- }
@@ -565,9 +565,44 @@ describe( 'global styles renderer', () => {
565
565
  },
566
566
  };
567
567
 
568
- expect( toStyles( Object.freeze( tree ), blockSelectors ) ).toEqual(
569
- ':where(body) {margin: 0;}.is-layout-flow > .alignleft { float: left; margin-inline-start: 0; margin-inline-end: 2em; }.is-layout-flow > .alignright { float: right; margin-inline-start: 2em; margin-inline-end: 0; }.is-layout-flow > .aligncenter { margin-left: auto !important; margin-right: auto !important; }.is-layout-constrained > .alignleft { float: left; margin-inline-start: 0; margin-inline-end: 2em; }.is-layout-constrained > .alignright { float: right; margin-inline-start: 2em; margin-inline-end: 0; }.is-layout-constrained > .aligncenter { margin-left: auto !important; margin-right: auto !important; }.is-layout-constrained > :where(:not(.alignleft):not(.alignright):not(.alignfull)) { max-width: var(--wp--style--global--content-size); margin-left: auto !important; margin-right: auto !important; }.is-layout-constrained > .alignwide { max-width: var(--wp--style--global--wide-size); }body .is-layout-flex { display:flex; }.is-layout-flex { flex-wrap: wrap; align-items: center; }.is-layout-flex > :is(*, div) { margin: 0; }body .is-layout-grid { display:grid; }.is-layout-grid > :is(*, div) { margin: 0; }' +
570
- ':root :where(.is-style-foo.wp-image.wp-image-spacing){padding-top: 2px;}:root :where(.is-style-foo.wp-image.wp-image-border-color){border-color: blue;}:root :where(.is-style-foo.wp-image){color: blue;}.wp-site-blocks > .alignleft { float: left; margin-right: 2em; }.wp-site-blocks > .alignright { float: right; margin-left: 2em; }.wp-site-blocks > .aligncenter { justify-content: center; margin-left: auto; margin-right: auto; }'
568
+ const hasBlockGapSupport = false;
569
+ const hasFallbackGapSupport = true;
570
+ const disableLayoutStyles = true;
571
+ const disableRootPadding = true;
572
+ const styleOptions = {
573
+ blockGap: false,
574
+ blockStyles: true,
575
+ layoutStyles: false,
576
+ marginReset: false,
577
+ presets: false,
578
+ rootPadding: false,
579
+ };
580
+
581
+ // Confirm no variation styles by default.
582
+ const withoutVariations = toStyles(
583
+ Object.freeze( tree ),
584
+ blockSelectors,
585
+ hasBlockGapSupport,
586
+ hasFallbackGapSupport,
587
+ disableLayoutStyles,
588
+ disableRootPadding,
589
+ styleOptions
590
+ );
591
+ expect( withoutVariations ).toEqual( '' );
592
+
593
+ // Includes variation styles when requested.
594
+ styleOptions.variationStyles = true;
595
+ const withVariations = toStyles(
596
+ Object.freeze( tree ),
597
+ blockSelectors,
598
+ hasBlockGapSupport,
599
+ hasFallbackGapSupport,
600
+ disableLayoutStyles,
601
+ disableRootPadding,
602
+ styleOptions
603
+ );
604
+ expect( withVariations ).toEqual(
605
+ ':root :where(.is-style-foo.wp-image.wp-image-spacing){padding-top: 2px;}:root :where(.is-style-foo.wp-image.wp-image-border-color){border-color: blue;}:root :where(.is-style-foo.wp-image){color: blue;}'
571
606
  );
572
607
  } );
573
608
 
@@ -881,6 +881,7 @@ export const toStyles = (
881
881
  marginReset: true,
882
882
  presets: true,
883
883
  rootPadding: true,
884
+ variationStyles: false,
884
885
  ...styleOptions,
885
886
  };
886
887
  const nodesWithStyles = getNodesWithStyles( tree, blockSelectors );
@@ -923,8 +924,8 @@ export const toStyles = (
923
924
  ruleset += `padding-right: 0; padding-left: 0; padding-top: var(--wp--style--root--padding-top); padding-bottom: var(--wp--style--root--padding-bottom) }
924
925
  .has-global-padding { padding-right: var(--wp--style--root--padding-right); padding-left: var(--wp--style--root--padding-left); }
925
926
  .has-global-padding > .alignfull { margin-right: calc(var(--wp--style--root--padding-right) * -1); margin-left: calc(var(--wp--style--root--padding-left) * -1); }
926
- .has-global-padding :where(.has-global-padding:not(.wp-block-block, .alignfull, .alignwide)) { padding-right: 0; padding-left: 0; }
927
- .has-global-padding :where(.has-global-padding:not(.wp-block-block, .alignfull, .alignwide)) > .alignfull { margin-left: 0; margin-right: 0;
927
+ .has-global-padding :where(:not(.alignfull.is-layout-flow) > .has-global-padding:not(.wp-block-block, .alignfull, .alignwide)) { padding-right: 0; padding-left: 0; }
928
+ .has-global-padding :where(:not(.alignfull.is-layout-flow) > .has-global-padding:not(.wp-block-block, .alignfull, .alignwide)) > .alignfull { margin-left: 0; margin-right: 0;
928
929
  `;
929
930
  }
930
931
 
@@ -1010,7 +1011,7 @@ export const toStyles = (
1010
1011
  );
1011
1012
  }
1012
1013
 
1013
- if ( styleVariationSelectors ) {
1014
+ if ( options.variationStyles && styleVariationSelectors ) {
1014
1015
  Object.entries( styleVariationSelectors ).forEach(
1015
1016
  ( [ styleVariationName, styleVariationSelector ] ) => {
1016
1017
  const styleVariations =
@@ -0,0 +1,128 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import { __ } from '@wordpress/i18n';
5
+ import { ToolbarButton } from '@wordpress/components';
6
+ import { arrowLeft, arrowUp, arrowDown, arrowRight } from '@wordpress/icons';
7
+ import { useDispatch } from '@wordpress/data';
8
+
9
+ /**
10
+ * Internal dependencies
11
+ */
12
+ import BlockControls from '../block-controls';
13
+ import { useGetNumberOfBlocksBeforeCell } from './use-get-number-of-blocks-before-cell';
14
+ import { store as blockEditorStore } from '../../store';
15
+
16
+ export function GridItemMovers( {
17
+ layout,
18
+ parentLayout,
19
+ onChange,
20
+ gridClientId,
21
+ blockClientId,
22
+ } ) {
23
+ const { moveBlocksToPosition, __unstableMarkNextChangeAsNotPersistent } =
24
+ useDispatch( blockEditorStore );
25
+
26
+ const columnStart = layout?.columnStart ?? 1;
27
+ const rowStart = layout?.rowStart ?? 1;
28
+ const columnSpan = layout?.columnSpan ?? 1;
29
+ const rowSpan = layout?.rowSpan ?? 1;
30
+ const columnEnd = columnStart + columnSpan - 1;
31
+ const rowEnd = rowStart + rowSpan - 1;
32
+ const columnCount = parentLayout?.columnCount;
33
+ const rowCount = parentLayout?.rowCount;
34
+
35
+ const columnCountNumber = parseInt( columnCount, 10 );
36
+ const rowStartNumber = parseInt( rowStart, 10 );
37
+ const columnStartNumber = parseInt( columnStart, 10 );
38
+
39
+ const getNumberOfBlocksBeforeCell = useGetNumberOfBlocksBeforeCell(
40
+ gridClientId,
41
+ columnCountNumber
42
+ );
43
+
44
+ return (
45
+ <BlockControls group="parent">
46
+ <ToolbarButton
47
+ icon={ arrowUp }
48
+ label={ __( 'Move block up' ) }
49
+ isDisabled={ rowStart <= 1 }
50
+ onClick={ () => {
51
+ onChange( {
52
+ rowStart: rowStart - 1,
53
+ } );
54
+ __unstableMarkNextChangeAsNotPersistent();
55
+ moveBlocksToPosition(
56
+ [ blockClientId ],
57
+ gridClientId,
58
+ gridClientId,
59
+ getNumberOfBlocksBeforeCell(
60
+ columnStartNumber,
61
+ rowStartNumber - 1
62
+ )
63
+ );
64
+ } }
65
+ />
66
+ <ToolbarButton
67
+ icon={ arrowDown }
68
+ label={ __( 'Move block down' ) }
69
+ isDisabled={ rowCount && rowEnd >= rowCount }
70
+ onClick={ () => {
71
+ onChange( {
72
+ rowStart: rowStart + 1,
73
+ } );
74
+ __unstableMarkNextChangeAsNotPersistent();
75
+ moveBlocksToPosition(
76
+ [ blockClientId ],
77
+ gridClientId,
78
+ gridClientId,
79
+ getNumberOfBlocksBeforeCell(
80
+ columnStartNumber,
81
+ rowStartNumber + 1
82
+ )
83
+ );
84
+ } }
85
+ />
86
+ <ToolbarButton
87
+ icon={ arrowLeft }
88
+ label={ __( 'Move block left' ) }
89
+ isDisabled={ columnStart <= 1 }
90
+ onClick={ () => {
91
+ onChange( {
92
+ columnStart: columnStartNumber - 1,
93
+ } );
94
+ __unstableMarkNextChangeAsNotPersistent();
95
+ moveBlocksToPosition(
96
+ [ blockClientId ],
97
+ gridClientId,
98
+ gridClientId,
99
+ getNumberOfBlocksBeforeCell(
100
+ columnStartNumber - 1,
101
+ rowStartNumber
102
+ )
103
+ );
104
+ } }
105
+ />
106
+ <ToolbarButton
107
+ icon={ arrowRight }
108
+ label={ __( 'Move block right' ) }
109
+ isDisabled={ columnCount && columnEnd >= columnCount }
110
+ onClick={ () => {
111
+ onChange( {
112
+ columnStart: columnStartNumber + 1,
113
+ } );
114
+ __unstableMarkNextChangeAsNotPersistent();
115
+ moveBlocksToPosition(
116
+ [ blockClientId ],
117
+ gridClientId,
118
+ gridClientId,
119
+ getNumberOfBlocksBeforeCell(
120
+ columnStartNumber + 1,
121
+ rowStartNumber
122
+ )
123
+ );
124
+ } }
125
+ />
126
+ </BlockControls>
127
+ );
128
+ }